Is a for attribute mandatory?

Do you ABSOLUTELY need a for attribute?

No, not in all cases. Only when the label element is a sibling of the input control is a for attribute recommended. From an assistive technology perspective it is a required attribute under accessibility guidelines (need to read up on this).

The LABEL is optional, when it comes down to it. It does make a lot of sense, though.

Here is a typical form from olden times…

<p>text <input></p>
<p><input> text</p>

But some authors used DIV, some used LI, and it was kind of up in the air in HTML 3.

HTML 4.0 introduced the LABEL element. Give this page a read,

and go to Label on MDN to read the documentation in modern terms.


When the INPUT is a child of LABEL, id and for are not needed, and rather moot. In reading accessibility guidelines, look for this distinction. It may be required (though not needed) in order to validate under WAI guidelines.