Development & testing

Form field without a label: fixing the “label” finding

What the message “Form elements must have labels” means, why placeholders are no substitute and how to label search, newsletter and contact fields correctly.

6 min readUpdated: Accessonaut editorial team Published on

In short

The message “Form elements must have labels” (axe rule label) means that an input field has no label that is technically associated with it. A screen reader then just says “edit text”, voice control cannot address the field by name, and clicking the label text does not put the cursor in the field. The most reliable fix is a visible <label> connected to the field via for and id.

What the rule checks

The rule examines input fields and text areas; hidden fields and buttons are excluded, and select menus are checked by the related rule select-name. A <label> with a matching for attribute, a <label> wrapping the field, aria-label and aria-labelledby all count as a label. axe maps the rule to WCAG success criterion 4.1.2 “Name, Role, Value”; in substance it is closely related to 1.3.1 “Info and Relationships” and 3.3.2 “Labels or Instructions”.

According to Deque, a placeholder attribute can also give a text field a name, so axe may not report a field that has a placeholder. Deque explicitly says this is not a recommended solution. The absence of a finding therefore does not automatically mean a good label.

Where the error usually hides

  • Search field in the header: just a magnifying glass and a placeholder, no label.
  • Newsletter in the footer: an email field from copied provider code without a <label>.
  • Label without association: the text is visible next to the field, but as a <p> or <div> rather than a <label>.
  • Broken association: the for attribute points to an id that does not exist or occurs more than once.
  • Multi-part input: day, month and year or postcode and town share a single label.
  • Spam traps: an invisible honeypot field is only moved off screen and can still be reached with the keyboard.

Why a placeholder is not enough

A placeholder disappears as soon as someone starts typing. Anyone who checks the form later or is interrupted while filling it in can no longer see what belongs in the field. Placeholder text is also often light grey and low in contrast, and some assistive technologies do not read it reliably. People with concentration or memory difficulties easily lose track. The WAI forms tutorial therefore recommends using placeholders, if at all, only as a supplement for format examples.

How to connect label and field

The standard solution is a visible label with a matching id: <label for="email">Email address</label> <input id="email" name="email" type="email" autocomplete="email">. Wrapping works equally well: <label>Email address <input type="email" name="email"></label>. The autocomplete attribute is not part of this rule, but it makes filling in easier and is the usual technique for WCAG 1.3.5 “Identify Input Purpose” on fields for personal data.

For a search field with a visible “Search” button, the label may be visually hidden: <label for="q" class="visually-hidden">Search this website</label>. The class must only hide the text visually; display:none removes it for screen readers too. Group related options such as radio buttons with <fieldset> and <legend> so that the question is announced with each option.

Tips for WordPress forms

Use the label field in your form plugin, not just the placeholder. If the plugin has an option to hide the label, check in the source code whether the <label> is still there afterwards and only visually hidden. Newsletter forms whose HTML you copied from your email provider can be given a <label> directly in the code.

The default WordPress search form includes a label that is visible to screen readers. If it is missing on your website, your theme has replaced the search form with its own template, and that is where the fix is needed.

Writing good labels

A label is short, visible and close to the field, usually above it. Mark required fields in the label text, for example “Phone number (required)”, rather than only with a coloured asterisk. Connect format hints such as “DD/MM/YYYY” to the field via aria-describedby. The article “Accessible forms” describes how to make error messages and the whole journey accessible.

Checking the fix

  1. Click the label text: if the cursor jumps into the field, the association is correct.
  2. Go through the form with the Tab key and a screen reader and listen to whether every field is announced with its label, type and, where relevant, required status.
  3. Check the computed name of every field in the developer tools under “Accessibility”.
  4. Run the website check again for every page that contains the form.

Sources & review status

Here you’ll find the original sources for this article. Last checked on .

Legal requirements depend on the country, the provider and the specific offer. This article explains the basics and practical steps. Test results apply to their documented scope and date.

More on Development & testing

Your next step

What does your website need?

Check a public page for automatically detectable barriers. The results show specific findings and help you prioritise.

Free website check

A sensible testing process

  • Find automatically detectable issues
  • Test the keyboard and real journeys manually
  • Fix, re-check and document
Guide to testing your website