Search topics
Icon-only buttons with no accessible name
The header's search, basket and menu buttons are drawn with SVG icons and contain no words, so each is announced only as "button".
<button><svg>…</svg></button> The problem
The header's buttons say what they do only in pictures, so screen reader and voice control users can't tell them apart
A stationery shop's header has the shop's name on the left and three round buttons on the right: a magnifying glass for search, a bag with a small "2" badge for the basket, and three lines for the menu. Sighted mouse users recognise the icons and click them. A screen reader user who presses Tab hears "button", then "2, button", then "button". Nothing tells them which one opens the menu.
Each button contains only an inline SVG drawn with a use reference to a sprite. An SVG with no title and no aria-label contributes no text, so the button has no accessible name. The only text inside is the badge's "2". The browser builds a button's name from the text inside it and finds none, and it draws the button just the same, so nothing on screen looks wrong.
That breaks two criteria. The magnifying glass, the bag and the three lines are non-text content doing a job, and 1.1.1 needs that job said in words: here "search", "basket" and "menu" exist only as pictures. 4.1.2 needs each control to have a name that software can read, and these three buttons have none (or only "2"), so assistive technology has nothing to announce or to match a spoken command against.
An icon alone assumes everyone sees it and knows what it means. A name in words reaches every way of using the page.
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 role with no purpose and have to press each button to find out what it does. In a list of form controls, the three entries are indistinguishable.
- Limited manipulation Voice control users say a button's name to press it; with no name they fall back to slow numbered overlays.
- Limited language, cognitive and learning abilities People who don't recognise an icon, such as three lines for a menu, gain from words.
axe's button-name reliably flags a button with no name. It does not judge the name, so it passes aria-label="icon", aria-label="magnifier" or a file name copied from the sprite. A quick AI fix often names the picture instead of the action, adds aria-label to the SVG but leaves the button empty, or names the basket "Basket" while the visible badge adds a stray "2". Whether the name makes sense is something only a person can check.
What the checkers report
- axe DevTools
- ARIA commands must have an accessible name
- Buttons must have discernible text
- Input buttons must have discernible text
- Lighthouse
button,link, andmenuitemelements do not have accessible names.- Buttons do not have an accessible name
- Input buttons do not have discernible text.
- WAVE
- Empty button
Try it
Press Tab to move through the header buttons
The panel shows what a screen reader announces. Can you tell which button opens the menu?
Broken Can you fix this?
The fix
Give each icon button a name in words
<header class="site-header"> <a href="/" class="logo">Fern & Fold</a> <button type="button" class="icon-button"> <svg class="icon"> <use href="#icon-search"></use> </svg> </button> <button type="button" class="icon-button"> <svg class="icon"> <use href="#icon-bag"></use> </svg> <span class="badge">2</span> </button> <button type="button" class="icon-button"> <svg class="icon"> <use href="#icon-menu"></use> </svg> </button></header>What is wrong3 points
- The search and menu buttons are announced only as "button". The SVGs give them no text, so they have no name.
- The basket is announced as "2, button", which doesn't say what it is. Its only text is the badge's "2".
- No one can tell the three apart by ear, or say a name to press one with voice control: each is announced as a button and nothing more.
Visually hidden text inside the button
<header class="site-header"> <a href="/" class="logo">Fern & Fold</a> <button type="button" class="icon-button"> <svg class="icon" aria-hidden="true"> <use href="#icon-search"></use> </svg> <span class="visually-hidden">Search</span> </button> <button type="button" class="icon-button"> <svg class="icon" aria-hidden="true"> <use href="#icon-bag"></use> </svg> <span class="badge" aria-hidden="true">2</span> <span class="visually-hidden">Basket, 2 items</span> </button> <button type="button" class="icon-button"> <svg class="icon" aria-hidden="true"> <use href="#icon-menu"></use> </svg> <span class="visually-hidden">Menu</span> </button></header>How it is fixed4 steps
- Put each button's words in a
span: "Search", "Basket, 2 items" and "Menu". They are real text in the page, so the buttons are announced as "Search, button", "Basket, 2 items, button" and "Menu, button", and browser translation translates them. - Hide those spans from view with the
visually-hiddenclass. - Hide the icons with
aria-hidden="true", so the words alone name the buttons. - Hide the badge with
aria-hidden="true"too. The hidden text already includes the count; without that, the count would be read twice.
This fixes the Before and passes 4.1.2 and 1.1.1.
All three give each button a name and meet 4.1.2 and 1.1.1. Hidden text keeps the design unchanged and is translated with the page, so it suits a header with no room for words. aria-label keeps the design too and is the simplest in a component, but some browser translation tools leave it in the original language. A visible label costs space, but it is the only option that also helps people who don't recognise the icon. Choose it where the layout allows, and use one of the other two where it doesn't.
Name the action, not the picture. "Search", "Close" and "Menu" describe what happens. "Magnifier", "X" and "Hamburger" describe the drawing, and a file name such as "icon-bag.svg" describes nothing. A toggle such as a favourite heart keeps one name and exposes its state with aria-pressed, rather than swapping the name.
Hide the icon, every time. Without aria-hidden="true", some screen readers announce an unnamed SVG as "image" or "group", and icon fonts can read out a private-use character. An SVG with its own title inside a named button is read twice in some combinations.
Tooltips are not names. A title attribute or a tooltip that appears on hover may be used as a fallback name, but not consistently, and it does not appear for touch or keyboard users in every browser. Name the button directly, and keep any tooltip text the same as the name.
Input buttons too. An <input type="submit">, type="button" or type="reset" takes its name from its value. One with value="", or a type="button" with no value, drawn as an icon in its background, has no name, and axe reports it as input-button-name. Give it a value that names the action, or replace it with a button element, which can hold the icon and hidden text like the fix above.
Components. Make the name a required prop of the shared icon-button component, so an unnamed button can't be built. If the prop is optional, it will be left out.
Counts and changing state. When the basket count changes, update the name as well as the badge. If people need to hear the change, announce it in a status region; changing a button's name alone is not announced. Add to cart buttons that change a badge and say nothing shows how.
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 icon-button component changes.
Limits
This is a starting pattern, not a guarantee for every application. The sprite ids and class names in the snippets are placeholders. Icon buttons added later by content editors or third-party widgets need the same check. Help text that points to an icon button by its look, such as "tap the magnifying glass", also needs the button's name: see instructions that rely on colour, shape or position. When a button shows words as well as an icon, its name must contain those words: see buttons and links named differently from their text. The minus and plus of a quantity stepper need names too, and a number that can be typed: see quantity steppers with unnamed buttons and no typing. The faces of a rating scale need their values as names, and the question tied to them: see smiley-face ratings announced only as "button". 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.