Element: ariaLabelledByElements property

Baseline 2025
Newly available

Since April 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The ariaLabelledByElements property of the Element interface is an array containing the element (or elements) that provide an accessible name for the element it is applied to.

The property reflects aria-labelledby (in some circumstances) and is similarly intended to provide a label for elements that don't have a standard method for defining their accessible name. The main difference is that the property can be used to provide label text from elements that don't have an id, and takes precedence over all other methods of setting the ARIA label.

Value

An array of elements. The inner text of these elements can be joined with spaces to get the accessible name.

When read, the returned array is a static and read-only. When written, the assigned array is copied: subsequent changes to the array do not affect the value of the property.

Description

The property is a flexible alternative to using the aria-labelledby attribute to set the accessible name. Unlike aria-labelledby, the elements assigned to this property do not have to have an id attribute.

For example, this might be used to label a container element, such as a <div> or <span> (provided it has been given an appropriate ARIA role). The property takes precedence over other mechanisms for providing an accessible name for elements, and may therefore also be used to provide a name for elements that would normally get it from their inner content or from an associated element such as a label.

The property reflects the element's aria-labelledby attribute when it is defined, but only for listed reference id values that match valid in-scope elements. If the property is set, then the corresponding attribute is cleared. For more information about reflected element references and scope see Reflected element references in the Reflected attributes guide.

See aria-labelledby for additional information about how the attribute and property should be used.

Examples

Get the accessible name

This example shows how ariaLabelledByElements can be used to get an ARIA label defined using aria-labelledby.

HTML

The HTML defines two <span> elements and references their ids in the aria-labelledby attribute of an <input>. The accessible name of the <input> is the concatenation of the inner text of the two referenced elements, separated by a space.

html
<span id="label_1">Street name</span>
<input aria-labelledby="label_1 label_2" />
<span id="label_2">(just the name, no "Street" or "Road" or "Place")</span>

JavaScript

The code below first logs the value of the aria-labelledby attribute from Element.getAttribute() (a string listing the id values of the referenced elements). It then checks whether the ariaLabelledByElements is supported, and if so, logs its value. Finally it returns the accessible string, calculated by iterating through the elements and concatenating their inner text.

js
const inputElement = document.querySelector("input");
log(`aria-labelledby: ${inputElement.getAttribute("aria-labelledby")}`);
// Feature test for ariaLabelledByElements
if ("ariaLabelledByElements" in Element.prototype) {
  // Get ariaLabelledByElements
  const labelElements = inputElement.ariaLabelledByElements;
  log(`ariaLabelledByElements: ${labelElements}`);

  // Log inner text of elements to get accessible name
  const text = labelElements.map((e) => e.textContent.trim()).join(" ");
  log(`Accessible name: ${text.trim()}`);
} else {
  log("element.ariaLabelledByElements: not supported by browser");
}

Result

The log below shows the original element references, the associated/returned elements, and the accessible name. Note that the example doesn't do anything with text entered into the street name <input>.

Specifications

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# dom-ariamixin-arialabelledbyelements

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
ariaLabelledByElements
Chrome – Full support
Chrome 135 (Release date: 2025-04-01)
footnote Full support
Edge – Full support
Edge 135 (Release date: 2025-04-04)
footnote Full support
Firefox – Full support
Firefox 136 (Release date: 2025-03-04)
footnote Full support
Opera – Full support
Opera 120 (Release date: 2025-07-02)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 135 (Release date: 2025-04-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 136 (Release date: 2025-03-04)
footnote Full support
Opera Android – Full support
Opera Android 89 (Release date: 2025-04-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 135 (Release date: 2025-04-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.4 (Release date: 2023-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also