Accessible name for ARIA command elements
Last updated:
How to give an ARIA command element an accessible name?
Use one of the following approaches:
<!-- Use aria-label -->
<div role="button" aria-label="Close dialog">
<svg>...</svg>
</div>
<!-- Use aria-labelledby to reference visible text -->
<span id="save-label">Save document</span>
<div role="button" aria-labelledby="save-label">
<svg>...</svg>
</div>
<!-- Include visible text content -->
<div role="button">Delete item</div>
<!-- Use title as a fallback -->
<div role="link" title="Go to homepage">
<img src="logo.png" alt="" />
</div>
The following element fails because it has no accessible name:
BAD:
<div role="button">
<svg aria-hidden="true">...</svg>
</div>
Why is this important?
Screen readers announce interactive elements by their accessible name. When an element has the role button, link, or menuitem but no accessible name, the screen reader cannot tell the user what the element does.
This issue occurs frequently when icon-only buttons are built with <div> or <span> elements instead of native <button> or <a> elements.
More info:
Rule info
Standard
WCAG A SC 4.1.2
User impact
Serious impact Significantly hinders users with disabilities. Should be fixed as a high priority. Critical : blocks access entirely Serious : significantly hinders use Moderate : causes difficulty Minor : minimal disruptionFix complexity
High level of required technical expertise To resolve this issue, you need technical expertise in software engineering. Resolving this issue requires modifying the software code, for which you need a background in software engineering.Affects
Visual People with vision related disabilities can include those with color blindness, low vision, or complete blindness. Providing alternative text (also known as alt text) for graphical content is especially important for these individuals, as it allows assistive technologies such as screen readers to describe the content to them.
Free Website Accessibility Audit
Was this article helpful?
Thanks for your feedback!