Home / Fix guides / Accessibility (WCAG)

How to fix "buttons do not have an accessible name"

This warning means a button shows only an icon (a magnifying glass, a cart, an X) and has no text a screen reader can read out. Fix it by giving each icon button a short label, either as visible text, as visually hidden text, or with an aria-label.

Many sites have buttons that show only a small picture: a magnifying glass for search, a bag for the cart, three lines for the menu, an X to close a pop-up. Sighted visitors understand them at a glance. A screen reader, the software that blind and low-vision people use to hear a page read aloud, only knows what is in the page code. If the button contains no text, it announces just "button". The visitor hears "button, button, button" and has to guess which one does what.

That is what the audit message "buttons do not have an accessible name" means. The accessible name is the text a screen reader, or voice control software, uses to identify the control.

What the problem looks like

On screen, nothing looks wrong. The problem is only visible in the code or when you use assistive technology. A typical broken button looks like this:

<button type="button">
  <svg>...</svg>
</button>

The same issue appears in other forms:

  • A link that wraps only an icon, such as a social media logo (audit tools call this a link with no discernible name).
  • A button made with an icon font, where the icon is a special character that may be read out as nonsense or skipped.
  • An image button (<input type="image">) with no alt text.
  • A clickable <div> or <span> styled to look like a button, which has no name and no role at all.

Why it matters

People who cannot see the icon cannot tell whether a button searches, opens the cart or closes a dialog. If the cart or checkout button is one of the unlabeled ones, those visitors cannot buy from you. Voice control users are affected too: they say "click search", and that only works if the button has a name.

It is also a legal and trust matter in many countries, because accessibility rules and laws commonly point to WCAG, the Web Content Accessibility Guidelines. This problem falls under success criterion 4.1.2 (Name, Role, Value). Fixing it takes minutes per button, so it is one of the cheaper accessibility wins.

How to check your site for free

  • Lighthouse in Chrome. Open your page, press F12, go to the Lighthouse tab, tick Accessibility and run it. Look for "Buttons do not have an accessible name" and "Links do not have a discernible name". The report shows the exact elements.
  • A browser extension. The free axe DevTools and WAVE extensions flag empty buttons and empty links directly on the page.
  • The Accessibility pane in DevTools. Right-click an icon, choose Inspect, and open the Accessibility tab. If the Name field is empty, the button has no accessible name.
  • A screen reader. NVDA is free on Windows and VoiceOver is built into Mac and iPhone. Press Tab through your header and listen. Anything announced only as "button" needs a label.

Check the header, mobile menu, search, cart, carousel arrows, pop-up close buttons, cookie banner and social icons first. Test the mobile layout too, since some icon buttons only exist there.

How to fix it in general

Pick one of three methods. Use the first when you can.

  1. Visible text. Show the word next to the icon ("Search", "Cart"). It helps everyone, not only screen reader users.
  2. Visually hidden text. Add a text label that is hidden on screen but still read by assistive technology. Many themes already include a class for this (WordPress uses screen-reader-text, Bootstrap 5 uses visually-hidden).
  3. An `aria-label`. Add the label as an attribute on the button.

With an aria-label, the fix looks like this:

<button type="button" aria-label="Search">
  <svg aria-hidden="true" focusable="false">...</svg>
</button>

The aria-hidden="true" on the icon stops it being announced as well, which avoids double or garbled speech, particularly with icon fonts.

A few rules for good labels:

  • Describe the action, not the picture: "Open menu", not "hamburger". "Close", not "X".
  • Keep it short and specific. If there are two carts or two close buttons on a page, make the names different enough to tell apart.
  • If the button also shows visible text, the accessible name should contain that same text, so voice control users can say what they see.
  • Do not rely on the title attribute alone. It is inconsistently read and invisible on touch screens.
  • If a clickable <div> is the problem, change it to a real <button>. Adding a label to a div does not give it keyboard support.

Fixing it on common platforms

Where you make the change depends on who wrote the icon button, so find its source first.

WordPress. The icon usually comes from your theme (header search, menu toggle) or a plugin (slider arrows, cart). Update the theme and plugin first, since many already fixed this. If not, see our WordPress guide, or ask the theme author. Do not edit a theme directly without a child theme, or the change is lost on the next update.

Shopify. Header icons for search, account and cart live in the theme code, often in a header section or snippet. Duplicate your theme as a backup first. In the theme menu, choose Edit code and look for a <button> or <a> that contains only an <svg>. Details are in the Shopify guide. Current theme versions often include labels, so updating may be enough.

Elementor. An icon widget or a button widget with the text removed has no name. In the widget's Advanced tab, look for Custom Attributes (this is an Elementor Pro feature) and add aria-label|Search. Otherwise keep a short visible text on the button.

Webflow. Select the element, open the settings panel and add a custom attribute with the name aria-label and the value you want.

Wix. Editor versions differ. Select the element and look for an accessibility or ARIA label field in its settings.

React and Next.js. Put aria-label on the button (<button aria-label="Close">). Component libraries such as Material UI expect an aria-label on their icon button component. The eslint-plugin-jsx-a11y package can warn you in the editor when one is missing.

How to confirm the fix worked

  1. Run Lighthouse or axe again on the same page and make sure the warning is gone.
  2. Inspect one fixed button and check that the Name field in the Accessibility pane shows your label.
  3. Tab through the page with a screen reader or just listen to the names announced. Each button should say what it does.
  4. Repeat on mobile width, and on pages that use a different template, such as the cart or checkout.

How to stop it coming back

  • Make "every icon button has a label" part of your checklist when adding any new button, widget or theme section.
  • Re-run an accessibility check after theme, plugin or page builder updates, since they can replace your buttons.
  • Ask developers to use real <button> elements and to include the label in the first version.
  • Test with the keyboard and a screen reader now and then, because automated tools only catch part of the problems.

SiteMonday runs a full WCAG 2.2 accessibility audit in week 7 of its yearly schedule and lists unlabeled buttons in the ranked fix list. Fixing them is up to you or your developer. Related problems often show up alongside this one, such as form fields without labels.

Step by step for your platform

Questions

What is an accessible name?

It is the text that assistive technology uses to identify a control, such as "Search" for a search button. It can come from visible text, hidden text or an aria-label.

Is aria-label or hidden text better?

Visible text is best, then visually hidden text, then aria-label. All three work for screen readers, but visible text also helps sighted and voice control users.

Do icons need alt text or an aria-label?

If the icon is inside a labeled button, hide the icon with aria-hidden="true" and label the button. If the icon is a standalone image that conveys meaning, give it alt text.

Does the title attribute count as a label?

It can provide a name as a last resort, but support is uneven and touch users never see it. Use visible text, hidden text or aria-label instead.

Will this fix hurt my design or my SEO?

No. Hidden text and aria-labels do not change how the page looks, and clear labels do no harm to search. The main effect is better usability for more of your visitors.

Do I need a developer to fix this?

Often not. On many platforms you can add a label in the element's settings, and a developer is only needed when the icon is generated in theme or app code you cannot edit.

Related problems