Rule

Label target references

label[for] must reference a form control that exists.

Rule
label-for-valid
WCAG 2.2
4.1.2 Name, Role, Value (opens in a new tab) (Level A)
Severity
Serious

What it checks

The rule follows the for attribute of every <label>. A label whose for names a form control passes. It fails a label that wraps a control while its for points somewhere else, when the wrapped control has no name from anywhere else: HTML lets for win over the wrapping, so the control the label surrounds is left without it.

When a person decides

A label whose for points at nothing, or at an element that cannot be labelled, such as a <div>, is sent for review. A label is not a control, so the broken link harms nothing by itself. If a field was meant to be there, form labels reports the field.

Example

Fails

<label for="email">
  Email address
  <input id="email-address" type="email">
</label>

Passes

<label for="email-address">
  Email address
  <input id="email-address" type="email">
</label>

The engine is tested against both examples.

How to fix it

Make the for attribute match the id of the control it labels. A label that wraps its control can also drop for altogether.

Check your own pages

This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.