input-missing-label
What it does
Section titled “What it does”Reports an <input> (not hidden and not a button), <select> or <textarea> that no label names: it is not inside a <label>, no <label for> points at its id, and it has no aria-label or aria-labelledby.
Why it matters
Section titled “Why it matters”A control without a name is read by a screen reader as just “edit text”, and the click target is only the control itself, not its text.
To fix, wrap the control in a <label>, or give it an id and a <label for>, or add aria-label.
Example
Section titled “Example”...<html lang="en"><head><title>x</title></head><body><input type="text" name="a"><label>L <input type="text" name="b"></label><label for="c">C</label><input type="text" id="c"><input type="text" aria-label="d">...Configuration
Section titled “Configuration”angular: lint: rules: input-missing-label: warn # off (default), warn, errorhtml: lint: rules: input-missing-label: warn # off (default), warn, errorsvelte: lint: rules: input-missing-label: warn # off (default), warn, errorvue: lint: rules: input-missing-label: warn # off (default), warn, errorEnabled by the presets: html/htmlhint.
Suppress one line with sudsy-disable-next-line input-missing-label in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| html-eslint | require-input-label |
full | |
| html-validate | input-missing-label |
partial | does not skip what is inside aria-hidden |
| htmlhint | input-requires-label |
full |