Accessibility

a11y/input-label

Every form field has a programmatic label (label element, aria-label or aria-labelledby); a placeholder is not a label.

criticalstaticWCAG 1.3.1, 3.3.2, 4.1.2 · Afe-a11y-forms

Why

A field without a programmatic label is announced only as "edit text": the user does not know what to type. A placeholder disappears on input, often has low contrast and is not reliably used as the accessible name.

Fix

Pair a visible <label for="email"> with <input id="email">, or wrap the field in the label. When the design has no visible label (a search field next to its button), use aria-label or aria-labelledby; keep a visible label wherever you can.

Examples

<!-- bad -->
<input type="email" placeholder="Email">
<!-- good -->
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email">

Sources

Facts

Id
a11y/input-label
Severity
critical
Check
static checked in the source by audit
Applies to
html angular vue svelte astro jsx
WCAG 2.2
1.3.1, 3.3.2, 4.1.2, level A
Same problem in
axe-core label, axe-core select-name
Taught by the skill
fe-a11y-forms Accessible forms
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain a11y/input-label