Is it proper if I place the tag after the input tag or before or does it matter?
<label for="l">Last Name:</label>
<input type="text" name="lname" id="l" />
<input type="text" name="fname" id="f" />
<label for="f">First Name:</label>
Is it proper if I place the tag after the input tag or before or does it matter?
<label for="l">Last Name:</label>
<input type="text" name="lname" id="l" />
<input type="text" name="fname" id="f" />
<label for="f">First Name:</label>
I put the input tag inside the label tag:
<label>Name: <input ... /></label>
That way, the for attribute isn't needed.
Both are valid XHTML, however for good accessibility it's probably best to have <label>
first so it'll be described by a screen reader before reaching the input itself.