Development & testing

Button without a name: labelling icon buttons accessibly

“Buttons must have discernible text” explained: why menu, close and slider buttons are affected and how to name them correctly with text or aria-label.

6 min readUpdated: Accessonaut editorial team Published on

In short

The message “Buttons must have discernible text” (axe rule button-name) means that a button has no accessible name. A screen reader only says “button”, and nobody finds out whether it opens the menu, closes a dialog or submits a form. It almost always affects buttons that only show an icon. Give them visible text, visually hidden text or an aria-label that names the action.

What the rule checks

The rule examines <button> elements and elements with role="button". They get a name from their text content, from aria-label, from aria-labelledby or, as a last resort, from the title attribute. If there is no name at all, axe reports a failure of WCAG success criterion 4.1.2 “Name, Role, Value” (Level A). For <input type="button"> and <input type="submit">, the related rule input-button-name applies; there the value attribute provides the name.

The title attribute is computed as a name, but it is only visible as a tooltip when hovering with a mouse. Keyboard and touch users usually do not see it. So use it as a supplement at most.

Typical candidates on websites

  • Menu button: the hamburger icon of the mobile navigation without text.
  • Close button: the × in dialogs, cookie banners and newsletter pop-ups.
  • Sliders and carousels: arrows for next and previous and dots for individual slides.
  • Search: a magnifying glass as the submit button next to the search field.
  • Shop functions: basket, wish list or quantity controls as icons only.
  • Media players: play, pause or sound as an icon without a label.

Giving the button the right name

Visible text helps everyone and is the first choice. If only an icon should be visible, give the button an aria-label and hide the graphic from assistive technologies: <button type="button" aria-label="Menu" aria-expanded="false"><svg aria-hidden="true" focusable="false">…</svg></button>. Visually hidden text works just as well: <button type="submit"><svg aria-hidden="true">…</svg><span class="visually-hidden">Search</span></button>.

For a close button with a × character, aria-label="Close dialog" replaces the announcement “times” or “multiplication sign”. The name describes the action, not the appearance: “Close” rather than “X”, “Menu” rather than “hamburger”. The word “button” does not belong in the name, because the screen reader already announces the role.

Expressing states with ARIA rather than the name

A menu button keeps its name “Menu” and uses aria-expanded="true" or "false" to report whether the navigation is currently open. The script that opens the menu must update the value every time. For a toggle such as “Mute” there are two clean options: either the name changes, or the name stays the same and aria-pressed shows the state. The W3C ARIA patterns explicitly advise against combining the two.

Real buttons instead of clickable divs

A <div> with a click handler does not appear in the finding at all, because it is not a button for assistive technologies. It also cannot be reached with the Tab key and does not respond to Enter or Space. So use <button type="button"> for actions on the page and <a href> for navigating to another address. The type attribute prevents a button inside a form from submitting it unintentionally.

If you have to keep an existing element with role="button", it also needs tabindex="0", a visible focus indicator and keyboard handling. Swapping it for a native element is almost always less work.

WordPress, themes and plugins

The WordPress Buttons block always contains text and is rarely the cause. Unnamed buttons usually come from the theme header (menu and search toggles), from slider and pop-up plugins or from embedded chat and cookie tools. Some page builders offer a field for an ARIA label or custom attributes on icon elements; use it where available.

If the source cannot be configured, report the finding with its selector to the vendor. For your own theme code, fix the template in a child theme so that the change survives updates.

Checking that the button is understandable

Run the website check again. Then tab to each corrected button and listen to what a screen reader announces: name, role and, where relevant, state, for example “Menu, button, collapsed”. Check the computed name in the developer tools under “Accessibility” and test whether the state actually changes when opening and closing.

Sources & review status

Here you’ll find the original sources for this article. Last checked on .

Legal requirements depend on the country, the provider and the specific offer. This article explains the basics and practical steps. Test results apply to their documented scope and date.

More on Development & testing

Your next step

What does your website need?

Check a public page for automatically detectable barriers. The results show specific findings and help you prioritise.

Free website check

A sensible testing process

  • Find automatically detectable issues
  • Test the keyboard and real journeys manually
  • Fix, re-check and document
Guide to testing your website