I'm using the following HTML code to create a form but the width of the "phone" label seems to be ignored no matter what I set it to. I've set it explicitly to 50px.
<div name="VGroup968" style="position:absolute;left:36px;top:54px;width:380px;height:166px;">
<div style="padding-bottom:6px"><div name="HGroup568" style="width:180px;height:23px;">
<div style="display:inline;padding-right:2px"><label name="Label589" style="position:relative;vertical-align: middle;width:50px;height:12px;font-family:Arial;font-size:12px;">Phone</label></div>
<div style="display:inline;"><input type="input" name="TextInput547" style="width:120px;height:22px;font-family:Arial;font-size:12px;padding:0;border:1px solid #696969;"/></div>
</div></div>
<div style="padding-bottom:6px"><div name="HGroup616" style="width:180px;height:23px;">
<div style="display:inline;padding-right:2px"><label name="Label665" style="position:relative;vertical-align: middle;width:50px;height:12px;font-family:Arial;font-size:12px;">Message</label></div>
<div style="display:inline;"><input type="input" name="TextInput554" style="width:120px;height:22px;font-family:Arial;font-size:12px;padding:0;border:1px solid #696969;"/></div>
</div></div>
Is there something I'm missing? http://jsfiddle.net/EsdQB/1/
The width property does not apply to non-replaced inline elements (such as label
).
Add display: inline-block
and it will work.
FIDDLE
From the w3c spec on the width property:
Applies to: all elements but non-replaced inline elements, table rows, and row groups
Also, see this answer which roughly sums up that non-replaced inline elements - means:
inline elements that can contain text like <a>, <span> <label>
etc.
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