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

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: