Is there an easy way to align a label with a textbox in all major browsers (i.e. including IE7? I set display to inline-block on my label and textbox which seems to work everywhere but in IE7, where the label is on the bottom of the div.
<label class="inputLabel" for="emailTextBox">
Email:</label>
<input class="textBox" type="text" id="emailTextBox" value=" Email address" />
input.textBox
{
margin-top: 5px;
margin-bottom: 5px;
height: 30px;
width: 350px;
font-size: 15px;
font-family: Verdana;
line-height: 30px;
display:inline-block;
}
label.inputLabel
{
font-family: Verdana;
font-size: 15px;
line-height: 30px;
display:inline-block;
}
The
display:inline-blockdeclaration is not fully supported by IE7 and below, so you have to usedisplay:inlineinstead in conjunction with thezoom:1hasLayout hack to imitate the declaration with the star hack to target IE7. To align both the textbox and labelwe can use thevertical-align:middleproperty, like so:CSS
Demo