ARIA label (aria-label)

aria-label is a WAI-ARIA attribute that gives an element its accessible name as a text string: the name a screen reader announces and speech control listens for, with no text shown on the page. It is meant for controls with no visible label, such as an icon-only button, and replaces the name the element would get from its own text.

The longer version

WAI-ARIA 1.2, the W3C Recommendation of 6 June 2023, defines aria-label as a property that "defines a string value that labels the current element", and it states the condition for using it in the same entry: if the label text is available in the page, typically as visible text, authors should use aria-labelledby, which points at that text, and should not use aria-label. The specification also lists where the property may not go. Naming is prohibited for the roles caption, code, deletion, emphasis, generic, insertion, paragraph, presentation, strong, subscript and superscript, and a plain div or span has the role generic, so an aria-label on one of them is invalid and may never be announced. Above all of it sits the first rule of ARIA use, from the W3C's Using ARIA: if you can use a native HTML element or attribute with the semantics and behaviour you require already built in, instead of re-purposing an element and adding an ARIA role, state or property, then do so. A button element with visible text needs no ARIA label at all.

The accessible name is computed in a fixed order, which the ARIA Authoring Practices Guide summarises. aria-labelledby is used if present. If the name is still empty, aria-label is used. After that come the host language's own mechanisms, such as the HTML label element, an image's alt, a fieldset's legend or a table's caption, then the element's content for roles that take their name from it, such as buttons and links, and the title attribute last, as a fallback. Three consequences follow, and each is a common bug. An aria-label on a button that has visible text replaces that text as the name. An aria-label on an input that also has a label element wins over the label. And an aria-label on an element that also has aria-labelledby is ignored, because aria-labelledby comes first, which is why the Authoring Practices Guide gives that aria-label the value "This is ignored" in its own example.

Most wrong ARIA labels are wrong in one of five ways. The name contradicts the visible text, as when a button reads Buy now and its aria-label says Add item to basket: that fails WCAG 2.2 Success Criterion 2.5.3 Label in Name, Level A, which asks that for a component whose label includes text, the name contains the text that is presented visually, and a person using speech control who says "click Buy now" finds nothing to click. The name repeats the role, as in Close button, which the Authoring Practices Guide advises against because the screen reader already announces the role. The attribute sits on a div, a span or a paragraph, where naming is prohibited. The label was never translated, which the guide also warns about, so a French page has English names nobody can see. Or the attribute is missing where it was needed, on an icon-only control whose name is now empty, which fails Success Criterion 4.1.2 Name, Role, Value, Level A.

A reviewer can spot every one of these without reading the source. Chrome's element picker shows the accessible name and role of whatever it hovers, and the Accessibility tab in the Elements panel shows the computed accessibility properties of the selected element, so the visible label and the announced name can be compared side by side. A screen reader pass, moving through the controls with Tab, gives the same answer by ear. The finding names the element, the visible text, the name that was announced, the criterion it fails and the browser and screen reader used. The accessibility checklist in the Notarus templates checks names under 4.1.2 in its structure group and lists 2.5.3 among the criteria a one-page pass leaves out, so a label mismatch is worth checking on purpose.

Common questions

What is aria-label used for?

aria-label gives an interactive element a name when nothing visible on the page can serve as one. The usual cases are icon-only buttons, such as a magnifying glass for search or a cross that closes a dialog, and landmarks that appear more than once, such as two navigation regions. Where a visible label exists, the specification asks for aria-labelledby or a native label instead.

What is the difference between aria-label and aria-labelledby?

aria-label holds the name as a string written into the attribute, and nobody sees it. aria-labelledby holds the id of one or more elements on the page, and the name is their visible text. When both are present, aria-labelledby wins. WAI-ARIA 1.2 says to use aria-labelledby when the label text is in the page, and aria-label only when it is not.

Can aria-label be used on a div or span?

A plain div or span has the role generic, and WAI-ARIA 1.2 lists generic among the roles whose naming is prohibited, so an aria-label there is invalid and may be ignored. Give the element a real role first, or better, use the native element that already has one, such as a button, a nav or a section with a heading.

Does aria-label override the text inside a button?

aria-label comes before the element's content in the accessible name computation, so on a button with visible text the screen reader announces the aria-label and ignores the text. Speech control users then have to guess the hidden name. WCAG 2.2 Success Criterion 2.5.3 Label in Name, Level A, asks that the name contains the visible text.

What does ARIA mean in coding?

ARIA stands for Accessible Rich Internet Applications, a W3C specification published by the Web Accessibility Initiative as WAI-ARIA. Its roles, states and properties are HTML attributes that tell assistive technology what an element is, what it is called and what state it is in. ARIA changes what is announced and never adds behaviour, so keyboard handling still has to be written.

What is the first rule of ARIA?

The W3C's Using ARIA states it: if you can use a native HTML element or attribute with the semantics and behaviour you require already built in, do so instead of re-purposing an element and adding an ARIA role, state or property. A native button is focusable, works with Enter and Space and is announced as a button with no ARIA at all.

What does aria-current do?

aria-current marks the element that represents the current item within a set of related elements, in the words of WAI-ARIA 1.2. The usual example is the link to the page being viewed in a navigation menu, given aria-current="page", so a screen reader announces it as the current page. Other values include step, date and location.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">