Now this can be done easily with tables, however, i want to know if there is sensible non table way to do this.
What i want is lets say labels on one side, left side top to bottom of greatly varying length. And input elements often multiple per line on other side however all input elements align at the same left edge which is about 100px away from all their labels and is not based on the length of the label.
I could use tables or css tables...however is there another way. Because It seems not very good idea especially to update and maintain a structure that is related but divided into separate entities.
I want to so that if it's possible to do this layout if possible without using tables/css tables...but if that is unpractical let me know.
Easy peasy!
<label>
tag.<span>
.<label>
with display: block
.<span>
with display: inline-block
with a width.HTML
<form>
<label>
<span>Name</span>
<input type="text" />
</label>
<label>
<span>Email</span>
<input type="email" />
</label>
<label>
<span>Password</span>
<input type="password" />
</label>
</form>
CSS
label
{
display: block;
}
label span
{
display: inline-block;
text-align: right;
width: 100px;
}
Example Fiddle: http://jsfiddle.net/3aJyd/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With