Skip to content
easeweb
Search topics

Form fields with missing or mismatched labels

A delivery form looks labelled, but one label is loose text, one points at the wrong id and one aria-label differs, so the visible words aren't the names.

WCAG 2.2
SC 1.3.1ASC 2.5.3A· new in 2.1SC 3.3.2A
Required by
Section 508 · EN 301 549 (EU)
Broken for="post-code"
The accessibility problem illustrated: No vision:Edit text for what?
01

The problem

Screen reader and voice control users can't tell which field is which, even though every field looks labelled, and a placeholder used as the label vanishes for everyone once they type

02

Try it

Fill in the form with the mouse, then press Tab to move through the fields

  • Broken 1: does clicking a label put you in its field? Below the form, compare the label you see with the name a screen reader hears.

  • Broken 2: type in a field and watch its label, in the field and below the form.

  • Apply a fix. Click each label and Tab through the fields again: do the label you see and the name you hear match?

Broken Can you fix this?

Full name
Phone

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Make the words people see the field's name

Before

Text that looks like labels, but isn't

<div class="field-title">Full name</div><input name="name" type="text"> <label for="post-code" class="field-title">Postcode</label><input id="postcode" name="postcode" type="text"> <div class="field-title">Phone</div><input name="phone" type="tel" aria-label="Contact number">
What is wrong3 points

It looks the same as the fixed version. But.

  • The name field is read only as "edit text": "Full name" is a loose div, not tied to the field.
  • The postcode field has no name either, and clicking "Postcode" does nothing: the label's for="post-code" points at an id that doesn't exist, as the field's id is postcode.
  • Saying "click Phone" does nothing: the field is named "Contact number" by its aria-label while the screen says "Phone".
After

Label elements

<label for="name">Full name</label><input id="name" name="name" type="text" autocomplete="name"> <label for="postcode">Postcode</label><input id="postcode" name="postcode" type="text" autocomplete="postal-code"> <label for="phone">Phone</label><input id="phone" name="phone" type="tel" autocomplete="tel">
How it is fixed3 steps
  1. Make each printed name a label, tied to its field by a matching for and id. The printed words are then the name: a screen reader says "Full name, edit text", voice control responds to "click Phone", and clicking the label moves focus to the field.
  2. Make the postcode's for match its id.
  3. Remove the aria-label, so nothing overrides the visible text.

This fixes both Befores and passes 1.3.1, 2.5.3 and 3.3.2.

Why this fix: Use native HTML first

Easily confused
04

Design ideas

A label can move, but it has to stay, in words

Three ways to label the same two fields, one filled in and one empty. Click each label, Tab through the fields and type in the empty one: two keep the name on screen in words, and one leaves only a picture.

In the design file

  • Each field twice: empty and filled in, with its label still visible in both.
  • Draw the focus ring, and where the label goes once the field has a value.
  • Use grey example text inside a field only alongside a real label, never instead of one.
  • Write the label colour’s contrast ratio next to it, checked at the smallest size the label shrinks to.

Passes

  • Floating label that stays In the empty field the label sits inside, #5c5650 at 7.24:1. On focus, or once there is a value, it moves up into a gap in the border at 13px, #4a4541 at 9.46:1, and stays there; while the field has focus it turns the site’s blue, #1a4fd0, 6.83:1.
  • Label inside a filled field A softly filled field with the label small at its top, 13px #4a4541 on #f6f4f2 at 8.63:1, and the value under it. The label never moves, empty or filled, and the edge and focus ring go round both.

Fails

  • An icon in place of each labelWCAG 3.3.2 A person and a map pin inside the fields, #5c5650 at 7.24:1, and no words. With “Alex Morgan” typed in, the person reads as a name, but the empty field’s pin could want an address, a town or a postcode: W3C accepts a picture as a label only when the people using the form widely understand it.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Forced colors

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared field component changes.

Limits

This is a starting pattern, not a guarantee for every application. Grouped controls such as radio buttons need a fieldset and legend as well, which this guide doesn't cover. A label that is there but too vague to say what to enter, such as Name on a form about two people, is covered in vague form labels that don't say what to enter. The same mismatch on a button or link, such as an aria-label that renames an "Add to bag" button, is covered in buttons and links named differently from their text. A label that points at the right id, in a form the page shows twice with the same ids, still names the first copy's field; that is covered in duplicate ids that point labels at the wrong field. Fields added by third-party widgets, payment iframes or content editors need the same check. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service