I have a form where the labels are on the left and the fields are on the right. This layout works great when labels have a small amount of text. I can easily set min-width on the labels so that they all have the same distance to the margins. In the first image below, this works as expected. The problem occurs when the label text becomes too long, either overflows to the next line, or clicks the field on one line to the left (as shown in Figure 2).
This does not push other shortcuts, so it remains βjaggedβ. Ideally, he would like to style it as image 3 with something like the following markup:
<fieldset> <label>Name</label><input type="text" /><br /> <label>Username</label><input type="text" /> </fieldset>
I created jsFiddle to show the problem.

Of course, a simple cross-browser way to solve this problem is to use tables. It just creates a hell tag for something that should be so simple. Note: this does not require IE6 support.
html css
TheCloudlessSky Jan 16 '11 at 18:50 2011-01-16 18:50
source share