HTML aria-label attribute
- type
- attribute
- applies to
- any element that needs a spoken name it doesn't already have
- lives inside
- the opening tag
- common values
- a short phrase: "Close", "Search", "Main navigation"
Where it goes
On the tag that needs a name: the icon-only <button>, the <nav> when there are several, the <svg> that carries meaning. Not needed where there is already visible text.
Example
<button aria-label="Close">✕</button>
<nav aria-label="Main">…</nav>Open this example in the editor →
Common mistakes
- Adding it to a tag that already has visible text. The label replaces that text for a screen reader (software that reads the page aloud). "Submit" on screen and aria-label="Go" is confusing.
- Putting it on a <div> or <span> to make it "accessible." Those have no role to attach the name to, so most readers ignore it. Use a real <button> or <a>.
- Reaching for aria when a plain attribute already does the job. alt on an image and <label> on a field do the same work with less to maintain.