Why don’t buttons and inputs align well in Bootstrap?
I tried something simple like:
<input type="text"/><button class="btn">button</button>
The button is about 5px lower than the input in chrome/firefox.

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Twitter Bootstrap 4
In Twitter Bootstrap 4, inputs and buttons can be aligned using the
input-group-prependandinput-group-appendclasses (see https://getbootstrap.com/docs/4.0/components/input-group/#button-addons)Group button on the left side (prepend)
Group button on the right side (append)
Twitter Bootstrap 3
As shown in the answer by @abimelex, inputs and buttons can be aligned by using the
.input-groupclasses (see http://getbootstrap.com/components/#input-groups-buttons)Group button on the left side
Group button on the right side
This solution has been added to keep my answer up to date, but please stick your up-vote on the answer provided by @abimelex.
Twitter Bootstrap 2
Bootstrap offers an
.input-appendclass, which works as a wrapper element and corrects this for you:As pointed out by @OleksiyKhilkevich in his answer, there is a second way to align
inputandbuttonby using the.form-horizontalclass:The Differences
The difference between these two classes is that
.input-appendwill place thebuttonup against theinputelement (so they look like they are attached), where.form-horizontalwill place a space between them.— Note —
To allow the
inputandbuttonelements to be next to each other without spacing, thefont-sizehas been set to0in the.input-appendclass (this removes the white spacing between theinline-blockelements). This may have an adverse effect on font-sizes in theinputelement if you want to override the defaults usingemor%measurements.