The Icon-Only Button Accessible-Name Checker parses your HTML and flags every button or a whose only content is an icon — an svg or img — with no accessible name. These controls are a top cause of screen-reader failures: a close button that is just an X icon announces as “button” with no hint of what it does. The checker enforces WCAG 1.1.1 (Non-text Content) and 4.1.2 (Name, Role, Value), both Level A.
How it works
The tool parses your markup with the browser’s DOMParser and inspects each button and a element.
- It computes whether the control has any accessible name from these sources, in priority order:
aria-labelledby,aria-label, visible text content (a non-empty text node), animgchild with non-emptyalt, ansvgchild containing a<title>, or atitleattribute. - It then checks whether the control’s only meaningful content is an icon (
svgorimg) with no text. - A control is flagged when it is icon-only and has none of the accessible-name sources above. Each flagged element is reported with its source snippet so you can find it in your codebase.
Tips and notes
- The simplest fix is
aria-label:<button aria-label="Close dialog">…</button>. - An
<img>inside a button should carry descriptivealttext; an emptyalt=""marks the image decorative and leaves the button nameless. - For inline SVGs, add a
<title>child orrole="img"witharia-label, and setaria-hidden="true"on the SVG only when separate visible text already names the button. - This catches missing names, not wrong ones — always confirm the label describes the action, not the icon (“Close”, not “X icon”).