Skiplink

Guides

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:

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:

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.

Try it on your own site: scan a URL for free, or read the docs to add a baseline to your pipeline.