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.
for="post-code" 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
A flower shop's checkout asks where to deliver. Three fields, "Full name", "Postcode" and "Phone", each have their name in bold above the box. It looks like any well-built form, and a sighted mouse user fills it in without trouble. A screen reader user who presses Tab hears "edit text" on the first field, "edit text" again on the second and "Contact number, edit text" on the third. A voice control user says "click Phone" and nothing happens. Nothing on screen hints at any of this. Many forms go further and drop the names above the boxes, putting them inside as grey placeholders instead; each one vanishes as soon as someone starts typing, and the filled-in form is left with three boxes of text and no word saying which is which.
"Full name" and "Phone" are div elements. They sit next to the fields, but nothing in the code connects them, so the first field has no accessible name. That fails 1.3.1: the relationship people see is not in the markup. "Postcode" is a real label, but its for="post-code" doesn't match the field's id="postcode", so it labels nothing: that also fails 1.3.1, and the field has no name. The phone field has aria-label="Contact number", which replaces the visible "Phone" as its name. 2.5.3 needs the visible words to be part of the name, so speaking what you see works. In the placeholder version, the grey text is the only label on screen, and the browser hides a placeholder as soon as the field holds a value. Once someone types, nothing on screen says what the field is for, which fails 3.3.2: a label has to stay there while the field is used, not only while it is empty.
Everyone loses the larger click target a real label gives: clicking "Full name" or "Postcode" does nothing.
3 of 10 groups affected
- No vision (affected)
- Low vision (not affected)
- Colour vision (not affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (affected)
- Reach, strength (not affected)
- Cognitive (affected)
- Seizures (not affected)
- Without vision Screen reader users hear a field type with no purpose, or a different name from the one a sighted colleague would read out to them.
- Limited manipulation Voice control users say the label they can see, and the field doesn't respond.
- Limited language, cognitive and learning abilities When the only label is a placeholder, it is gone once the field is filled in, so checking an answer means remembering what each box asked for.
A visual review finds nothing: every field has its name above it. axe's label rule finds the first two fields, but it counts the aria-label as a name, so the phone field passes even though it doesn't match what is shown. A quick AI fix often adds aria-label to every field: the scanner goes quiet, the broken for stays broken, and the names may still differ from the printed text. Whether the name matches the visible words is something a person has to compare.
What the checkers report
- axe DevTools
- Form field must not have multiple label elements
- Elements must have their visible text as part of their accessible name
- Form elements should have a visible label
- Form elements must have labels
- Lighthouse
- Form fields have multiple labels
- Form elements do not have associated labels
- WAVE
- Multiple form labels
- Unlabeled form control with title
- Missing form label
- Empty form label
- Orphaned form label
- Select missing label
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?
The fix
Make the words people see the field's name
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 ispostcode. - Saying "click Phone" does nothing: the field is named "Contact number" by its
aria-labelwhile the screen says "Phone".
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
- Make each printed name a
label, tied to its field by a matchingforandid. 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. - Make the postcode's
formatch itsid. - 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
Both make the visible text the field's name and pass 1.3.1, 2.5.3 and 3.3.2. Use label elements: they do the same job with plain HTML, and clicking the label focuses the field, which aria-labelledby does not do. Keep aria-labelledby for markup you can't restructure, such as a third-party template, and replace it with a label when you can. Fields labelled only by placeholders have no text to point at, so they need label elements.
Placeholders are hints, not labels. A placeholder can show an example, such as "SW1A 1AA", but only next to a real label. Grey placeholder text is also often below the contrast a label needs.
Wrapping is fine too. <label>Phone <input type="tel"></label> associates the label without for and id. It is the same fix as the first option, and it suits components that can't generate ids. Some older voice control software is more reliable with for and id.
Label first in the name. If a field needs more context for screen reader users, add it with aria-describedby or hidden text after the visible label, so the name starts with the words people see. "Phone, for the courier" still passes 2.5.3; "Courier contact, phone" is fragile.
One source for the name. A field's name comes from one place, in a fixed order: aria-labelledby first, then aria-label, then the label element. So when you add aria-labelledby, remove any aria-label left on the field: it is silently ignored, and the next person to edit it will think it still counts. An aria-label left beside a label wins in the same way and hides the visible words, as the phone field shows.
One label element per field. A second label pointing at the same field, often added for screen readers or to show an error, is handled differently by different assistive technologies: some read only one of the two, so part of the label or the whole error is never heard. Keep one label, and tie a hint or an error to the field with aria-describedby. axe reports a second label as form-field-multiple-labels.
Hidden labels. A search box with a visible "Search" button can take its label from that button with aria-labelledby. A visually hidden label is a last resort: it names the field for screen readers but leaves 3.3.2 depending on the surrounding design.
Components. Make the label a required prop of the shared field component and generate the id and for together in the component. A hand-typed for that is one character off, as in the example, is invisible in review.
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.
Verify the fix
4 checks, no mouse.
Test with: Keyboard, Screen reader, Zoom, Forced colors
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.
References
- WCAG Understanding: info-and-relationships (opens in a new tab)
- WCAG Understanding: label-in-name (opens in a new tab)
- WCAG Understanding: labels-or-instructions (opens in a new tab)
- WAI Tutorial: forms/labels (opens in a new tab)
- WAI Tutorial: forms/instructions (opens in a new tab)
- developer.mozilla.org: label (opens in a new tab)
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.