Skip to content
easeweb
Search topics

Invalid ARIA that misleads screen readers

A gift-wrap checkbox points aria-labelledby at a renamed label id, or writes its role as aria-role, so a screen reader hears a nameless box or no checkbox.

WCAG 2.2
SC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken aria-labelledby="gift-wrap-label" … id="giftwrap-label"
The accessibility problem illustrated: No vision:What is this box for?
01

The problem

Screen reader users can't tell what the gift-wrap box is for, or that it can be ticked at all

02

Try it

Tab to the gift-wrap box, then tick it and clear it with Space

  • Broken 1: listen to the box, empty and then ticked. Does the voice say what the box is for?

  • Broken 2: tick the box. Does the voice say what the box is, or whether it is ticked?

  • Apply a fix. Tick the box and clear it again. Does the voice say what the box is for, that it is a checkbox, and whether it is ticked?

Broken Can you fix this?

Gift wrap this order

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Write the ARIA as ARIA defines it, or use a native checkbox

Before

Aria-labelledby pointing at an old id

<div class="tick-box" role="checkbox" aria-checked="false" aria-labelledby="gift-wrap-label" tabindex="0"></div><span id="giftwrap-label">Gift wrap this order</span>
What is wrong3 points

The role and the state are right, and the tick is drawn. The name is where it fails.

  • Nobody listening can tell what the box is for. A screen reader says only "checkbox, not checked".
  • The checkbox has no name. A reference to an id that isn't on the page is skipped, and the words aren't inside the box to stand in for it.
  • The reference points at nothing. The box points at gift-wrap-label, and the label's id is giftwrap-label.
After

The ARIA written as ARIA defines it

<div class="tick-box" role="checkbox" aria-checked="false" aria-labelledby="gift-wrap-label" tabindex="0"></div><span id="gift-wrap-label">Gift wrap this order</span>
How it is fixed4 steps
  1. Give the box its role with role="checkbox".
  2. Point aria-labelledby at an id that is on the page, so the words beside the box become its name.
  3. Keep aria-checked at "true" or "false", switched by Space and by a click.
  4. Draw the tick from aria-checked itself, so what is shown and what is heard can't drift apart.

A screen reader says "Gift wrap this order, checkbox, not checked" and then "checked" after Space or a click. This fixes both Befores and passes 4.1.2. With the words inside the box, as in the second Before, the name comes from them, and role and aria-checked are enough. Where a template renders the option, build both ids from one value, so a rename changes both. The page must render aria-checked="true" when gift wrap is already chosen, for example in a saved basket.

A checkbox often stays a custom div for one of these reasons. Each can stay, as long as it leaves the role, the name and the state intact.

  • A look of its own for the box and the tick: draw the tick from aria-checked, as here, not from a class of its own.
  • A component library or framework that renders the box as a div: keep the role, a name from an id that is on the page, aria-checked and the Space key in what it renders.
  • A label placed apart from the box in the layout: build its id and the box's aria-labelledby from one value, so a rename changes both.

04

Verify the fix

5 checks.

Test with: Screen reader, Keyboard, Mouse

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat whenever the component or the code that saves its state changes.

Limits

This is a starting pattern, not a guarantee for every application. Class names are placeholders, and the checkbox stands for any custom control whose ARIA is written by hand. Browsers handle author errors in their own ways and change between versions, so a page that sounds right in one browser proves little. A custom box drawn beside a native checkbox hidden with display: none is a different failure, covered in custom checkboxes that keyboards and screen readers skip. A reference to an id that exists twice, because a component is shown more than once, finds the first copy; that is covered in duplicate ids that point labels at the wrong field. A name that exists but leaves out the words on screen is also a different failure, covered in buttons and links named differently from their text. Valid ARIA is not the same as correct ARIA: a scan that reports nothing can't tell you that a role suits the control or that its state follows the screen. 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