Form fields without labels, and why a placeholder is not a label
An unlabelled field is announced as "edit text, blank", and the user is left to guess. The fix is old, simple HTML. The trap is that a placeholder can make the scanner happy without helping anyone.
What the rule checks
axe-core's label (opens in a new tab) rule reports form
fields that have no accessible name: text inputs, textareas, checkboxes, radio buttons and
the like. In the criteria table it maps to
4.1.2 Name, Role, Value (opens in a new tab),
level A. Neighbouring rules cover the rest of a form: select-name for <select>,
aria-input-field-name for custom widgets with roles like combobox or textbox, and
form-field-multiple-labels for a field with more than one <label>, which maps to
3.3.2 Labels or Instructions (opens in a new tab).
Hidden inputs (type="hidden") are not checked; they are not presented to anyone.
What fails
<!-- Text beside the field, but nothing connects them -->
<span>Email</span>
<input type="email" name="email">
<!-- A label that points at an id that does not exist -->
<label for="postcode">Postcode</label>
<input type="text" id="post-code" name="postcode">
<!-- A select with only an "instruction" option -->
<select name="country">
<option>Choose a country</option>
…
</select>
The second is the most common in real codebases: someone renamed an id and the label quietly stopped working. It looks identical on screen, and clicking the label no longer focuses the field, which is the one quick manual test that would have caught it.
Fixes, in order of preference
An explicit <label>. Works everywhere, gives a bigger click target, and survives
translation.
<label for="email">Email</label>
<input type="email" id="email" name="email" autocomplete="email">
A wrapping <label>. No ids to keep in sync, which suits components.
<label>
Email
<input type="email" name="email" autocomplete="email">
</label>
aria-labelledby, when the visible text already exists and cannot become a
<label>, such as a column heading in a table of inputs.
<th id="qty-head">Quantity</th>
…
<td><input type="number" aria-labelledby="qty-head" name="qty-1"></td>
aria-label, for the rare field whose purpose is visually obvious from layout, such as
a search box next to a search button. It is invisible, so use it sparingly.
<input type="search" name="q" aria-label="Search the site">
<button>Search</button>
MDN's page on the label element (opens in a new tab)
covers the details, including which elements a <label> can be associated with.
Placeholder is not a label
This is the part a scanner will not help with.
<input type="email" name="email" placeholder="Email address">
Under the browser's accessible-name rules, a placeholder is used as a name when nothing
better exists, and axe-core's label rule accepts it. This field passes. It is still a
poor label, for reasons no rule can see:
- It disappears when you type. Anyone who looks away, is interrupted, or has a short working memory loses track of what the field was for. On a long form, reviewing your answers before submitting means deleting them to see the question.
- It is usually low contrast. Placeholder text is styled light grey on purpose, to look unlike a value. That makes it hard to read for exactly the people who most need the label.
- It looks like a value. Some users skip a field because it appears already filled in.
- It is not reliably announced. Support varies between screen reader and browser combinations, and autofill can hide it entirely.
Use a visible label, and keep the placeholder, if at all, for an example of the format:
<label for="phone">Phone number</label>
<input type="tel" id="phone" name="phone" autocomplete="tel" placeholder="07700 900123">
The same applies to title on its own: the rule accepts it as a name, but it appears only
on mouse hover.
Beyond the label
A labelled field can still be a hard field to fill in. Some of what makes forms work is detectable and much of it is not:
- Autocomplete. 1.3.5 Identify Input Purpose (opens in a new tab)
wants
autocompleteon fields that collect personal data. axe-core'sautocomplete-validchecks that a value you used is valid; it cannot know a field should have had one. - Errors. 3.3.1 Error Identification (opens in a new tab)
has no automated rule. Connect error text with
aria-describedbyso it is read with the field, and say what went wrong in words, not only with a red border. - Groups. A set of radio buttons needs a question as well as option labels, usually
a
<fieldset>with a<legend>. No rule checks that the question is there. - Label quality. "Field 1" is a label. 2.4.6 Headings and Labels (opens in a new tab), which asks that labels describe their purpose, has no automated rule at all.
Checking the forms you actually have
Most forms sit behind something: a sign-in, a basket, a previous step. A hosted scanner cannot reach them, but a check inside your Playwright tests can, including the error state after a failed submit. Whatever runs the check, a pass means no detectable violations, not a usable form; the list of what no scanner detects is the rest of the review.
Related
- Accessible names for icon buttons and links (button-name, link-name)
- What automated testing can and cannot detect — WCAG 2.2 reference
- Playwright Accessibility Testing Adapter
Try it on your own site: scan a URL for free, or read the docs to add a baseline to your pipeline.