Skip to main content

label-for-references-labelable

Per HTML Living Standard §4.10.4, the for attribute on a <label> element identifies the labeled control. If present, its value must be the ID of a labelable element in the same tree — button, input (except when type="hidden"), meter, output, progress, select, or textarea.

ID existence itself is the responsibility of no-refer-to-non-existent-id. This rule fires only when the referenced ID resolves to a non-labelable element.

❌ Examples of incorrect code for this rule

<label for="notaformcontrol">Label</label>
<div id="notaformcontrol">Just a div</div>

✅ Examples of correct code for this rule

<label for="username">Username</label> <input type="text" id="username" />

Interface

{
"label-for-references-labelable": boolean
}

Require that a label element's for attribute references an actual labelable element by ID.

Default Severity

error