How to fix buttons without a name
WCAG 4.1.2 Name, Role, Value, level A. Rule button-name in axe-core.
What is wrong
A button has no text that assistive technology can read. On shop sites these are the menu button, the close cross of a pop-up, the plus and minus of a quantity field, carousel arrows and the wishlist heart. A screen reader says "button", and nothing tells the visitor what it does.
Who it blocks
Screen reader users and voice control users.
How to fix it
<!-- before -->
<button class="menu-toggle"><svg ...></svg></button>
<!-- after -->
<button class="menu-toggle" aria-label="Open menu" aria-expanded="false"><svg aria-hidden="true" ...></svg></button>
Name the action, not the icon: "Open menu", "Close", "Increase quantity", "Next image", "Add to wishlist".
Common mistakes
- Using a
divorspanwith a click handler instead of abutton: it cannot be reached with the keyboard either. - A name that never changes on a toggle, for example "Play" on a video that is already playing.
- Using
titlealone: it is not read reliably and does not appear on touch screens.
How the scan proposes a fix
The scan adds an aria-label guessed from the button's class or id (menu, close, search, cart, next and similar words), or an EDIT ME text when nothing can be guessed. It runs the same rule on the fixed markup and checks that no existing attribute changed.
Check your own pages for free
Drag this button onto your bookmarks bar: Scan with accessaudit. Then open a page of your shop and click the bookmark: a score and the three main defects appear in a few seconds. The check runs in your browser: no content of your page leaves it, only the scanner is downloaded from this site. Try it on a demo shop.