Rampsight

All rules

Forms

Form fields need a label

Why it matters

An unlabelled input is announced as "edit, blank". The person can hear that a field exists but not what belongs in it, and the error on submit will not explain it either.

How to fix it

  1. Add a <label for="..."> whose value matches the field id.
  2. Where the design has no room, use aria-label with the same wording the placeholder shows.
  3. A placeholder is not a label: it disappears on the first keystroke and often fails contrast.

In markup

Fails
<input type="email" id="email">
Passes
<label for="email">Email</label>
<input type="email" id="email">

The requirement behind it

This rule is one way of failing the following WCAG 2.2 success criteria. The W3C, which writes the standard, explains each of them:

Further reading

Deque University on label (opens in new tab)

Deque maintains axe-core, the open-source engine our scanner runs. Their page documents the rule as the engine implements it.

Automated checks find failures a browser can prove. They cannot judge whether a caption is accurate, whether an alt text is useful, or whether a page can be operated end to end with a keyboard — those need a person.