Barrierepruefung.de Web Accessibility Checker

Form field without a label

The finding means an input field has no name that assistive technology can read. Often a label is visible next to it but not associated with the field, or the for attribute points to the wrong id. Use a label element that belongs to the field through for and id, or that wraps it.

Last reviewed: Sources

The message

Identifier
label
Type of check
automatic
Severity
critical
Meaning
The input field has no programmatically associated label.
Impact
Screen reader users do not learn what to enter in the field.
Fix
Associate a <label for="…"> with the field, or set an aria-label.

How does your website stand?

The free check shows what can be measured automatically, with the location. No account.

Check website for free

What the rule checks

axe looks at every <input> and every <textarea>. Buttons (type="submit", reset, button, image) and hidden fields (type="hidden") are left out; drop-down lists are covered by the separate rule select-name. A field passes if it gets a name in one of these ways: a <label> wrapping it, a <label for> pointing to its id, aria-label, aria-labelledby, a non-empty title or a non-empty placeholder.

A placeholder being enough only means that this rule passes. It disappears as soon as someone types and does not replace the visible label that 3.3.2 Labels or Instructions (Level A) asks for.

Common causes

  • Text next to the field, but not associated. <span>Email</span> <input type="email"> looks labelled, yet the field itself has no name. The W3C lists this as a failure (F68).
  • for and id do not match. A typo, a duplicated id, or an id that a framework regenerates on every render while the for is fixed in the template.
  • Label hidden. The <label> is hidden with display: none to save space, which removes it for screen readers as well.
  • Fields from widgets. A search field in the header, a newsletter field in the footer, date pickers and filters from plugins that bring only an icon, or nothing at all.

How to fix it

Associate label and field through for and id (H44):

<label for="email">Email address</label>
<input type="email" id="email" name="email" autocomplete="email">

Or let the <label> wrap the field, in which case no id is needed:

<label>
  Postcode
  <input type="text" name="postcode" autocomplete="postal-code">
</label>

If the label should not be visible, for a search field with a magnifier icon for example, hide it visually only instead of using display: none:

<label for="search" class="visually-hidden">Search this site</label>
<input type="search" id="search" name="q">
<button type="submit">Search</button>
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

If the label lives elsewhere, such as in the header cells of a table of input fields, compose it from several parts with aria-labelledby (ARIA16):

<table>
  <tr>
    <td></td>
    <th id="from">from</th>
    <th id="to">to</th>
  </tr>
  <tr>
    <th id="mon">Monday</th>
    <td><input type="time" aria-labelledby="mon from"></td>
    <td><input type="time" aria-labelledby="mon to"></td>
  </tr>
</table>

Afterwards, check that every id occurs only once on the page. How relationships are marked up in code is explained on the page about WCAG 1.3.1.