Question: I have a quick question about the usage of the `for` attribute in `<label>` tags. I know they should refer to the `id` of the input element they label, but I often see it being used to refer to the `name` attribute of some `<input>` tag in HTML forms. Is this valid usage?

Additionally, how should I label a set of, say, `<input type="radio">` tags? They each require an individual label, of course, but how do I correctly label the group they form?

Thanks in advance!

Answer: 
The [`label` element](http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.9) is defined in HTML 4.01 so that the `for` attribute “matches field ID value”. This is even a purely syntactic requirement: the attribute is declared with type `IDREF`, and this implies that an HTML validator issues an error message if the value does not match an `id` attribute value in the same document. In HTML5, the formalism is different, but the principle is the same.

Thus, it *must* match an `id` attribute value, and this is enforced by browsers: the element won’t act as a label for anything, functionally, is this requirement is violated. The page would still work, but with reduced usability and accessibility. The same value *may* appear as a `name` attribute value, too, since such attributes have a name space of their own, so to say.

There is no way to “label” a set of radio buttons, or other controls, in the sense that `label` defines labels (i.e., clicking on a `label` element typically focuses on the associated control). And no need either.

You can, and normally should, have a heading-like caption for a set of radio buttons, explaining what they are about. But that’s not a job for `label`. You can use a suitable heading element (e.g., `h2`), for example. A construct specifically designed for the purpose is the [`legend` element](http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.10) in a `fieldset` element. It can contain a brief description of the radio buttons wrapped inside a `fieldset`.
The for attribute says which element the label is meant for or belongs to.

<http://www.w3schools.com/tags/att_label_for.asp>