Dostępność

a11y/input-label

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

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

Dlaczego

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.

Poprawka

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.

Przykłady

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

Źródła

Fakty

Identyfikator
a11y/input-label
Waga
krytyczna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
html angular vue svelte astro jsx
WCAG 2.2
1.3.1, 3.3.2, 4.1.2, poziom A
Ten sam problem w
axe-core label, axe-core select-name
Uczy jej skill
fe-a11y-forms Accessible forms
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

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