Skip to content

input-missing-label

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.

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.

Reported
...
<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">
...
angular:
lint:
rules:
input-missing-label: warn # off (default), warn, error
html:
lint:
rules:
input-missing-label: warn # off (default), warn, error
svelte:
lint:
rules:
input-missing-label: warn # off (default), warn, error
vue:
lint:
rules:
input-missing-label: warn # off (default), warn, error

Enabled by the presets: html/htmlhint.

Suppress one line with sudsy-disable-next-line input-missing-label in a comment of the file’s language.

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