Evgeny Pokhilko's Weblog

Programmer's den

Align label and input vertically

On an html form we usually have the following layout:

[Label][Input_TextBox]

or

[Input_CheckBox][Label]

By default a label can be a bit higher than the text box. The solution is to apply this CSS to both the elements:

.inputOrLabel {

display:inline-block;

vertical-align:middle;

}

Vertical alignment of blocks is difficult in other cases. See this article for more details.

June 12, 2013 Posted by | ASP.NET, CSS | Leave a comment