tags:

views:

36

answers:

3

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>
+2  A: 

I put the input tag inside the label tag:

<label>Name: <input ... /></label>

That way, the for attribute isn't needed.

pzr
Older versions of IE has a problem with implicit labels.
Gert G
+4  A: 

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.

cxfx
If the screen reader user tabs through the form, it doesn't matter which side (or even where) the `label` is, as long as it's associated with the `input`. But I agree, the `label`/`text` should be first. That's were most visual user are used to see it.
Gert G
+1  A: 

no. It doesn't matter. The input can be anywhere on the page for that matter.