The following code seems to render the input field on the line below its label in all browsers:
<html>
<head>
<style type="text/css">
label { display:inline-block; width:75px }
</style>
</head>
<body>
<form>
<label>First Name <input type="text" name="first_name" size="30" maxlength="30"/></label>
</form>
</body>
</html>
This is how it appears:
First Name
[input field]
My understanding is that inline-block should allow for a fixed width for the label, whilst still permitting the input element to be inline. This is how I expected it to appear:
First Name [input field]
Why does the addition of a fixed width for the label in this instance not allow for both elements to appear inline?
Albeit your version is semantically correct, you have to do it like this to get your desired behavior:
HTML
CSS
Fiddle
That way, the
labeland theinputare separated from each other and can flow free. If thelabelholds theinput, that is not the case; even when setting thelabeltodisplay: inline-block.