label-req-for
If set, each label
tab must have a for
attribute. This practice helps screen readers, and improves form element selection by allowing the user to focus an input by clicking on the label.
The following patterns are considered violations:
<label>
<input type="text" id="thing"/>
</label>
<label for="noexist">
<input type="text" id="thing"/>
</label>"
<label>
<p>not labeable</p>
</label>
<div>
<label for="para"></label>
<div id="para"></div>
</div>
The following patterns are not considered violations:
<label for="thing">The Thing</label>
<input type="text" id="thing"/>
<label for="thing">
<input type="text" id="thing"/>
</label>