How do I vertically align a label, input control and button across different divs in HTM5 and CSS3?


I'm alignment issues with some controls in HTML5.

Consider the following HTML5 block:

<form action="#" method="post">
    <div class="divInput">
        <label for="something">Sample Label</label>
        <input type="input" name="something" id="something" class="inputClass"/>
    <div class="divInput">
        <button>It's a buttonnnnnn!</button>

with the following CSS3 styling info:
fieldset {
    font-size: 1em;
    padding: 0.5em;
    border-radius: 1em;
    font-family: sans-serif;

  padding-left: 2%;

  width: 86%;
label, input, button {
    font-size: inherit;
    padding: 0.2em;
    margin: 0.1em 0.2em;
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;

This is actually a small snippet from a larger, more complicated layout that I have.
If I use the above mentioned HTML and style info,  the button seems to "kind of" align
itself vertically with the label.

What I'd like is for the button to align itself with the input control.
So roughly speaking, I'd like to see this:
|Input Control|          |Button|

How would I achieve this?

Here is a link the sample in jsFiddle:
jxbmaSoftware ConsultantAsked:
Who is Participating?
Tom BeckConnect With a Mentor Commented:
You could add this definition:

div.divInput button{
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:

What you want is html like below. Then give the row a width in px not % if you don't want it to wrap.  Then give the inside class your float left and width and padding not more then the row class.

<div class="row">
    <div id="thing_one" class="inside"></div>

   <div id="thing_two" class="inside"></div>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.