New Tool Radar

AI Design Workflows

How to Check That a Button Label Matches Its Visible Name

Check that a control's accessible name starts with its visible label, because voice control users speak the words they can see.

Schematic with three steps: read the visible label, read the accessible name, check the name starts with the label.

A voice control user says the words they see on screen. If a button shows the word Search but its accessible name is Submit query, the spoken command does nothing. WCAG requires the accessible name to contain the visible label, so what you see is what you can say.

Why this needs its own check

WCAG 2.1 success criterion 2.5.3 Label in Name, Level A, requires that where a component has a visible label, its accessible name includes that visible text, normally at the start. The WCAG 2.2 checklist carries the same requirement forward, and it is the criterion that makes voice control work.

What you need before you start

  • The page open in a browser
  • Browser developer tools or an accessibility inspector to read accessible names
  • A list of buttons, links, and inputs with visible labels

Step 1 – Read the visible label

Write down the exact visible text on each button, link, and input label, exactly as it appears, including capitalisation.

Step 2 – Read the accessible name

Use the accessibility inspector to read the accessible name of the same control. Screen readers announce this name, and voice control matches against it.

Step 3 – Compare the two

The accessible name must start with the visible label text. A button labelled Search with the accessible name Submit query fails; a button labelled Search with the accessible name Search the catalogue passes.

Worked example

Practice check: a fictional Bluebell Nursery shop page

The example below is fictional. Bluebell Nursery is an invented business used only as a practice case. No real customer, page, or product is shown. Treat it as a practice case, not as evidence about any real business.

Part What it should be As shown Result
Search button Name starts with visible label Visible Search, name Search the catalogue Pass
Basket button Name starts with visible label Visible Basket, name View basket Fail – name does not start with Basket
Newsletter input Name starts with visible label Visible Email, name Email address Pass
Menu button Name starts with visible label Visible Menu, name Open navigation Fail – name does not start with Menu

Only 2 of the 4 checks pass: the search button and the newsletter input. The two failures are the basket button and the menu button, whose accessible names do not start with their visible labels.

What to do when something is wrong

Change the accessible names to start with the visible words: View basket becomes Basket, view your basket, and Open navigation becomes Menu, open navigation. Keep the visible label unchanged.

Expected result. We checked the WCAG 2.2 checklist listed in Sources. We did not inspect a live Bluebell Nursery page. UNTESTED: no accessibility inspector was run on a real page; the practice table shows the expected result pattern for a page with two mismatched accessible names.

Limits

  • This check covers visible labels only. Icon-only buttons with no visible text are covered by other criteria, and this check does not test whether the name is announced correctly by every screen reader.

Sources

See all