JavaScript Element ariaLabelledByElements Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline 2025
Instance property

What You’ll Learn

Element.ariaLabelledByElements is an instance property that holds an array of elements providing an accessible name. Learn how it relates to aria-labelledby, why label targets do not need an id when you set the property, and how to get or set the relationship from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Returns

Element array

03

Writable

Yes (get / set)

04

Reflects

aria-labelledby

05

Status

Baseline 2025

06

Use for

Accessible names

Introduction

Every control needs an accessible name. Often that name already exists as visible text on the page—a heading, a caption, or a short instruction next to a field. ARIA can point to those nodes with aria-labelledby.

ariaLabelledByElements is the modern element-reference form: you work with real DOM nodes instead of only managing id strings. Join their text with spaces to get the accessible name.

JavaScript
const labelledBy = input.ariaLabelledByElements;
const text = labelledBy.map((e) => e.textContent.trim()).join(" ");
console.log(text);
💡
Beginner tip

Prefer ariaLabelledByElements (or aria-labelledby) when the name is already visible. Use ariaLabel for a string name when there is no suitable visible text (for example an icon-only button).

Understanding the Property

MDN: 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. It is similarly intended to provide a label for elements that do not have a standard method for defining their accessible name.

  • Get / set — read or assign an array of elements.
  • Flexible alternative to the aria-labelledby attribute.
  • No id required on label nodes when you set the property (MDN).
  • Takes precedence over other ARIA label methods (MDN).
  • Reflection — reads valid in-scope id refs from the attribute; setting the property clears the attribute.

📝 Syntax

JavaScript
ariaLabelledByElements

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 static and read-only.
  • When written, the assigned array is copied—later edits to that array do not change the property.

⚖️ Property vs aria-labelledby Attribute

AttributeProperty
APIaria-labelledby="id1 id2"el.ariaLabelledByElements
Points toSpace-separated id stringsArray of Element objects
Targets need id?YesNo (when set via property)
After you set the propertyCorresponding attribute is cleared (MDN)

📋 Input Labelled by Spans (MDN Shape)

MDN’s example links an input to two spans via aria-labelledby. The accessible name is the concatenation of both spans’ text, separated by a space:

JavaScript
<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>

Related naming APIs: ariaLabel (string name) and ariaDescribedByElements (longer help text, not the short name).

⚡ Quick Reference

GoalCode / note
Feature-detect"ariaLabelledByElements" in Element.prototype
Readel.ariaLabelledByElements
Writeel.ariaLabelledByElements = [a, b]
Build name stringarr.map((e) => e.textContent.trim()).join(" ")
Attribute formaria-labelledby="id1 id2"
MDN statusBaseline Newly available (Apr 2025)

🔍 At a Glance

Four facts about Element.ariaLabelledByElements.

Kind
get / set

Instance

Type
Element[]

Static copy

ARIA
aria-labelledby

Reflected

Baseline
2025

Newly available

Examples Gallery

Examples follow MDN Element: ariaLabelledByElements. Labs feature-detect first so older browsers still show a clear message.

📚 Getting Started

Detect support and read MDN’s street-name example.

Example 1 — Feature-Detect

Check whether the reflected property exists.

JavaScript
if ("ariaLabelledByElements" in Element.prototype) {
  console.log("ariaLabelledByElements is supported");
} else {
  console.log("ariaLabelledByElements not supported by browser");
}
Try It Yourself

How It Works

Matches MDN’s feature test before reading or writing the property.

Example 2 — Get Label Elements (MDN)

Read the attribute ids, then the element array and the joined accessible name.

JavaScript
const inputElement = document.querySelector("input");

console.log("aria-labelledby:", inputElement.getAttribute("aria-labelledby"));

if ("ariaLabelledByElements" in Element.prototype) {
  const labelElements = inputElement.ariaLabelledByElements;
  console.log("count:", labelElements.length);
  const text = labelElements.map((e) => e.textContent.trim()).join(" ");
  console.log("Accessible name:", text.trim());
} else {
  console.log("ariaLabelledByElements not supported by browser");
}
Try It Yourself

How It Works

The property resolves valid in-scope id references from aria-labelledby into real element objects. Joining textContent rebuilds the name AT announces.

📈 Set Array, Attribute Sync & Snapshot

Assign label nodes without ids and verify reflection rules.

Example 3 — Set Label Array

Assign elements that have no id; the attribute is cleared after set.

JavaScript
const input = document.createElement("input");
const a = document.createElement("span");
const b = document.createElement("span");
a.textContent = "Email address";
b.textContent = "(work account)";
document.body.append(a, input, b);

if ("ariaLabelledByElements" in Element.prototype) {
  input.ariaLabelledByElements = [a, b];
  console.log({
    count: input.ariaLabelledByElements.length,
    attrAfterSet: input.getAttribute("aria-labelledby"),
    text: input.ariaLabelledByElements.map((e) => e.textContent).join(" ")
  });
} else {
  console.log("ariaLabelledByElements not supported by browser");
}
Try It Yourself

How It Works

MDN: setting the property clears the corresponding attribute. Label nodes do not need ids when linked this way.

Example 4 — Attribute Ids vs Resolved Elements

Compare the id string with the resolved element ids from the property.

JavaScript
const input = document.querySelector("input");

console.log({
  fromAttribute: input.getAttribute("aria-labelledby"),
  supported: "ariaLabelledByElements" in Element.prototype,
  fromProperty: "ariaLabelledByElements" in Element.prototype
    ? input.ariaLabelledByElements.map((el) => el.id)
    : null
});
Try It Yourself

How It Works

Prefer the property in script when supported; keep id-based aria-labelledby as a markup fallback for older browsers.

Example 5 — Support Snapshot

Feature-detect and review static-array rules.

JavaScript
console.log({
  supported: "ariaLabelledByElements" in Element.prototype,
  tip: "Returned array is static/read-only; assigned arrays are copied",
  pairsWith: "ariaDescribedByElements for longer help text",
  status: "Baseline Newly available (MDN, Apr 2025)"
});
Try It Yourself

How It Works

Re-assign a fresh array when label nodes change. Do not mutate an old array and expect the relationship to update.

🚀 Common Use Cases

  • Inputs labelled by multiple visible text fragments.
  • Containers or custom roles that need a name from nearby headings.
  • Dynamic UIs that attach label nodes without assigning ids.
  • Overriding a default accessible name with explicit label elements (MDN: takes precedence).
  • Custom elements via ElementInternals.ariaLabelledByElements.

🔧 How It Works

1

You point to label nodes

Via aria-labelledby ids or an element array.

Wire
2

Browser resolves element references

Valid in-scope refs become the property array.

Resolve
3

Text is joined for the accessible name

Inner text of each label element, separated by spaces.

Name
4

Assistive tech announces that name

Users hear the same wording that appears on screen.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline 2025—feature-detect older browsers).
  • Takes precedence over other methods of setting the ARIA label (MDN).
  • Returned arrays are static/read-only; assigned arrays are copied.
  • Related: ariaLevel, ariaDescribedByElements, EventTarget, JavaScript hub.

Browser Support

Element.ariaLabelledByElements is Baseline Newly available (MDN: across latest browsers since April 2025). Logos use the shared browser-image-sprite.png sprite from this project. Feature-detect on older browsers.

Baseline Newly available

Element.ariaLabelledByElements

Element[] — reflects aria-labelledby for accessible name element references.

Baseline Newly available (2025)
Google Chrome Supported (reflected element refs)
Yes
Microsoft Edge Supported (reflected element refs)
Yes
Mozilla Firefox Supported (reflected element refs)
Yes
Apple Safari Supported (reflected element refs)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No — use aria-labelledby + getElementById
No
ariaLabelledByElements Baseline 2025

Bottom line: Use ariaLabelledByElements to point at elements that supply the accessible name. Prefer it when the name is already visible. Feature-detect, and keep aria-labelledby ids as a markup fallback when needed.

Conclusion

ariaLabelledByElements reflects aria-labelledby as an array of elements so you can build accessible names from real DOM nodes—even without ids when you set the property. Prefer visible label text, feature-detect on older browsers, and use ariaLabel only when no suitable visible name exists.

Continue with ariaLevel, ariaDescribedByElements, EventTarget, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Reuse visible text as the accessible name
  • Feature-detect before reading or writing
  • Join label text in document order
  • Re-assign a new array when label nodes change
  • Keep aria-labelledby ids as a markup fallback

❌ Don’t

  • Mutate a returned array and expect updates
  • Confuse name (labelled-by) with description (described-by)
  • Point to empty or unrelated nodes
  • Skip feature detection on older browsers
  • Forget that this property can override other naming methods

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaLabelledByElements

Reflected element array for aria-labelledby accessible names.

5
Core concepts
📝 02

No id needed

when setting property

Flex
🔍 03

Static copy

not a live array

Rule
04

Baseline 2025

feature-detect

Status
🎯 05

Precedence

overrides other labels

MDN

❓ Frequently Asked Questions

An array of elements that provide an accessible name for the element. Join their inner text with spaces to form the accessible name string.
No. MDN marks Element.ariaLabelledByElements as Baseline 2025 (newly available since April 2025). It is not Deprecated, Experimental, or Non-standard. Feature-detect on older browsers.
The attribute uses space-separated id strings. The property uses Element references. Assigned elements do not need an id. Setting the property clears the corresponding attribute.
ariaLabel is a string name on the element itself. ariaLabelledByElements points to other elements whose text becomes the name. Prefer labelled-by when the name already exists as visible text on the page.
Yes. MDN notes the property takes precedence over all other methods of setting the ARIA label, including content and associated label elements.
No. When read, the returned array is static and read-only. When written, the assigned array is copied—later changes to that array do not update the property.
Did you know?

Because ariaLabelledByElements can take precedence over other naming methods, it is a powerful way to force a specific accessible name for widgets that would otherwise pull a name from their own text content—use that carefully so sighted and AT users stay aligned.

Next: Element ariaLevel

Learn the reflected aria-level property for hierarchical level within a structure.

ariaLevel →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful