Access 12.4.1.2

From Htmlpedia
Jump to: navigation, search

Access: [12.4.1.2]: associate labels explicitly with form controls (for) (Priority 2)

Cause:

The "for" attribute must accompany the "id" attribute to explicitly associate a label with its matching form control. The value of the "for" and "id" attributes must be identical. More than one label may be associated with the same control by creating multiple references via the "for" attribute.

Example:

Bad
<form action="">
  <input id="control1" value="****" type="text" />
</form>
Bad
<form action="">
  <label>Some text:</label>
  <input id="control1" value="****" type="text" />
</form>
Good
<form action="">
  <label for="control1">Some text:</label>
  <input id="control1" value="****" type="text" />
</form>

Solution:

For each input with an "id", create a corresponding label tag with a corresponding "for" for each "id"

References: