views:

314

answers:

3

When using the "label for" parameter on radio buttons, to be 508 compliant, is the following correct?

 <label for="button one"><input type="radio" name="group1" id="r1" value="1" /> button one</label>

or is this?

 <input type="radio" name="group1" id="r1" value="1" /><label for="button one"> button one</label>

Reason I ask is that in the second example, "label" is only encompassing the text and not the actual radio button.

+3  A: 

You almost got it. It should be this:

<input type="radio" name="group1" id="r1" value="1" /><label for="r1"> button one</label>

The value in for should be the id of the element you are labeling.

Marc W
A: 

With the use of a correct id and for (as stated by Marc W in another answer) actually BOTH are conforming to 508. Here's an example using labels in different ways, claiming it is in fact compliant.

Emil Stenström
+1  A: 

I believe either structure is valid and accessible, but the for attribute should be equal to the id of the input element:

<input type="radio" ... id="r1"><label for="r1" /> button text</label>

or

<label for="r1"><input type="radio" ... id="r1" /> button text</label>
Martha
True, although in the second example, the "for" attribute is not required.
Ishmael
I think there were some browser versions that only made the button text "clickable" if you used the 'for' attribute, i.e. wrapping the input inside the label wasn't enough.
Martha