Hi,
The label tag doesn't have the property 'width', so how should I control the width of a label tag?
Regards
Javi
Hi,
The label tag doesn't have the property 'width', so how should I control the width of a label tag?
Regards
Javi
Using CSS, of course...
label { display: block; width: 100px; }
The width
attribute is deprecated, and CSS should always be used to control these kinds of presentational styles.
Inline elements (like P, SPAN, LABEL, etc.) are displayed so that their height and width are calculated by the browser based on their content. If you want to control height and width you have to change those elements' blocks.
display: block;
makes the element displayed as a solid block (like DIV tags) which means that there is a line break after the element (it's not inline). Although you can use display: inline-block
to fix the issue of line break, this solution does not work in IE6 because IE6 doesn't recognize inline-block. If you want it to be cross-browser compatible then look at this article: http://webjazz.blogspot.com/2008/01/getting-inline-block-working-across.html