Skip to content

multiple-labeled-controls

Reports a <label> with no for that holds more than one control.

A label names only the first control it holds, so the second control has no name and a click on the label text goes to the wrong one.

To fix, give each control its own label, with for and id.

Reported
...
<label for="c">C</label><input type="text" id="c">
<input type="text" aria-label="d">
<input type="hidden" name="e">
<label>a <input id="x"> <input id="y"></label>
...
angular:
lint:
rules:
multiple-labeled-controls: warn # off (default), warn, error
html:
lint:
rules:
multiple-labeled-controls: warn # off (default), warn, error
svelte:
lint:
rules:
multiple-labeled-controls: warn # off (default), warn, error
vue:
lint:
rules:
multiple-labeled-controls: warn # off (default), warn, error

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

Suppress one line with sudsy-disable-next-line multiple-labeled-controls 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 multiple-labeled-controls full