Skip to content
easeweb
Search topics

Buttons and links named differently from their text

A shop gave each "Add to bag" button an aria-label naming the product and saying "cart", so the name no longer contains the words on the button and voice control can't find it.

WCAG 2.2
SC 2.5.3A· new in 2.1
Required by
EN 301 549 (EU)
Broken aria-label="Add Linen tote to cart"
The accessibility problem illustrated: Motor:Why won't it click?
01

The problem

Voice control users can't press the shop's "Add to bag" buttons by saying what they see, and screen reader users hear other words than the ones on screen.

02

Try it

Say “Click Add to bag” with the simulated voice control, then press Tab to reach each button.

Voice control looks for a button whose name holds the words you said. Under the grid is what a screen reader hears.

Broken Can you fix this?

BrokenAn aria-label with other words
  • Linen tote

    $48

  • Enamel mug

    $18

Voice control (simulated):

Screen reader says:

(Tab to a button)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Start each button's name with its visible words, and put the product after them or in a description.

  1. 1A button's or link's name contains the words it shows, and starts with them.
  2. 2Add context after the visible words, or as a description, never in place of them.
  3. 3Never hide the visible words with aria-hidden and name the control with other words.
Before An aria-label with other words
<ul class="products">  <li class="card">    <img src="linen-tote.jpg" alt="">    <h3>Linen tote</h3>    <p class="price">$48</p>    <button type="button" aria-label="Add Linen tote to cart">Add to bag</button>  </li>  …</ul>
After

The button's own words, with the product as a description

<ul class="products">  <li class="card">    <img src="linen-tote.jpg" alt="">    <h3 id="product-linen-tote">Linen tote</h3>    <p class="price">$48</p>    <button type="button" aria-describedby="product-linen-tote">Add to bag</button>  </li>  …</ul>

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Verify the fix

4 checks, no mouse.

Test with: Speech input, Screen reader, Keyboard

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 button or product card component changes.

Limits

This is a starting pattern, not a guarantee for every application. Speech software differs in how it matches what is said, so test with the voice control your users have. Buttons that third-party widgets or content editors add need the same check. Whether a name that starts with the visible words also says enough about its product is a separate question, covered for links in empty image links and vague "Read more" links. 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.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work