Skip to content

no-redundant-for

Reports a <label> whose for names a control that is inside the label.

The label already names the control it holds, so the for and the id it needs say the same thing twice, and they can drift apart when one is renamed.

To fix, remove the for (and the id if nothing else uses it).

Reported
...
<p id="a-b_c"></p>
...
<label for="x"><input type="text" id="x"></label>
<label for="y">y</label><input type="text" id="y">
...
angular:
lint:
rules:
no-redundant-for: warn # off (default), warn, error
html:
lint:
rules:
no-redundant-for: warn # off (default), warn, error
svelte:
lint:
rules:
no-redundant-for: warn # off (default), warn, error
vue:
lint:
rules:
no-redundant-for: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended.

Suppress one line with sudsy-disable-next-line no-redundant-for in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
html-validate no-redundant-for full