aria-label

On this page 7

aria-label is a WAI-ARIA attribute that assigns an element an accessible name in the form of a plain text string, which assistive technologies such as screen readers announce instead of, or in the absence of, visible text. In web accessibility, it is used mainly for interactive controls that have no visible text label, such as icon-only buttons, close controls and search fields marked only by a magnifying glass.

The attribute changes only what the accessibility tree exposes, not what sighted users see or how the element behaves. That makes it powerful and risky at the same time: a correct value can rescue an unlabeled control, while a wrong or unnecessary value can hide the visible text from screen reader users or create a mismatch with voice control commands.

How aria-label sets the accessible name

The browser computes an accessible name for each element using the Accessible Name and Description Computation specification, and aria-label sits high in its order of precedence. Only aria-labelledby outranks it; when aria-label is present and valid, it overrides native sources such as element content, the label element or the title attribute.

PrioritySourceTypical use
1aria-labelledbyPoints to visible text elsewhere on the page
2aria-labelSupplies a string when no visible label exists
3Native labelingLabel element, alt text, legend, caption
4Element contentText inside buttons, links and headings
5title or placeholderLast-resort fallback, unreliable
Simplified precedence of accessible name sources

Because of this precedence, writing aria-label="Menu" on a button whose visible text reads “Open navigation” means a screen reader announces only “Menu”. The visible text is silently replaced, which is why the attribute should be added only when a better source is missing.

The value is exposed through platform accessibility APIs such as UI Automation, AT-SPI and the macOS accessibility protocol. A screen reader typically reads the name together with the ARIA role and state, for example “Close, button” or “Search, edit text”.

Where aria-label works and where it does not

aria-label is reliable only on elements that support naming from the author, which means interactive elements and landmarks. On generic elements without a meaningful role, browsers and screen readers often ignore the value, and the ARIA specification prohibits naming certain roles.

Element or roleEffect of aria-labelRecommendation
Button, link, inputReliably sets the accessible nameUse when no visible text exists
Landmarks such as navDistinguishes repeated regionsUse, for example “Primary” and “Footer”
Dialog or regionNames the containerPrefer aria-labelledby to the visible heading
Plain div or spanOften ignored, naming prohibitedAdd a proper role or use visible text
Paragraph or generic textProhibited for these rolesDo not use
Support for aria-label by element type

Landmark labels deserve special care. When a page has two navigation landmarks, labels such as “Primary” and “Breadcrumb” let screen reader users tell them apart in a landmarks list. The word “navigation” should not be repeated in the label, because the role is already announced.

aria-label compared with other labeling techniques

aria-label is one of several ways to name an element, and it is usually not the first choice. The guiding principle known as the first rule of ARIA says to use a native HTML element or attribute with the needed semantics whenever possible.

TechniqueVisible to sighted usersMain advantageMain drawback
Label elementYesNative, clickable, robustOnly for form controls
aria-labelledbyYesReuses existing visible textRequires stable element IDs
aria-labelNoQuick fix for icon controlsNot translated, easy to forget
Visually hidden textNoTranslated with the pageRequires a utility CSS class
alt attributeOnly when image failsNative for imagesOnly for images
Labeling techniques and their trade-offs

A notable weakness is localization. Many automatic translation tools translate visible text but skip attribute values, so an English aria-label may remain in a page translated into another language. Visually hidden text inside the element avoids this problem and is often preferred for multilingual sites.

aria-label should also not be confused with aria-describedby, which adds a supplementary accessible description such as a hint or error message. The name says what the control is; the description adds detail announced after it.

Writing an effective aria-label value

A good aria-label is short, specific and action-oriented, so the user understands the purpose of the control without seeing it. It should describe what the control does, not what the icon looks like.

  • Write “Close dialog” rather than “X”, and “Search” rather than “Magnifying glass icon”.
  • Do not include the role in the label: “Submit” is announced as “Submit, button”, so “Submit button” becomes redundant.
  • Make repeated controls unique, for example “Delete invoice 1042” instead of five identical “Delete” buttons.
  • When visible text exists, the accessible name should start with the visible text to satisfy WCAG 2.5.3 Label in Name and support voice control users.
  • Keep the value in the page language and update it when the control state changes, or use aria-pressed or aria-expanded for state.

Relevant WCAG success criteria include 4.1.2 Name, Role, Value, which requires every user interface component to have a programmatic name, and 2.5.3 Label in Name, which requires the visible label text to appear in that name.

Common aria-label mistakes and how to fix them

Most aria-label defects found in an accessibility audit come from applying the attribute automatically or out of habit rather than from missing it entirely. Tools such as WAVE and Pa11y detect some problems, but manual testing with a screen reader such as NVDA remains necessary.

SymptomCauseFix
Visible link text is never announcedaria-label overrides contentRemove the attribute
Voice command “click Buy” failsLabel does not match visible textStart the name with the visible words
Label not read on a divUnsupported roleUse a button or add a valid role
English label on a translated pageAttribute not translatedUse visually hidden text
Icon announced as “image, chevron”Decorative icon exposedHide the icon with aria-hidden
Frequent problems with aria-label

An accessibility overlay that injects aria-label values automatically cannot reliably infer intent and often produces generic or misleading names. Fixing labels in the source code is the only dependable approach.

In everyday language

Some buttons on websites show only a small picture, such as an X or a magnifying glass. People who can see the screen understand them at a glance, but a blind person using software that reads the page aloud would hear nothing useful.

aria-label is a hidden name tag attached to such a button. Nobody sees it on screen, but the reading software says it out loud, for example “Close” or “Search”. The main rule is to use it only when there is no visible word, because the hidden tag replaces whatever text the button already shows.

Seen in the real world

An online grocery store runs an accessibility review before a public sector contract. Testing with NVDA reveals that the header contains six icon-only buttons, including cart, account and menu, which are announced only as “button”. Product cards also repeat “Add” forty times per page without saying which product.

The developers add aria-label values such as “Shopping cart, 3 items” and “Open main menu”, and change the product buttons to visible text “Add” with visually hidden text naming the product, so the accessible name becomes “Add Organic oat milk 1 liter”. They also remove an old aria-label on a promotional link that had been hiding its visible text.

The follow-up test shows no unnamed controls under WCAG 4.1.2, voice control users can say “click Add” successfully, and the translated Spanish version announces product names correctly because the hidden text is translated with the page.