JavaScript Element ariaLabel Property

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

What You’ll Learn

Element.ariaLabel is an instance property that reflects the aria-label attribute. Learn how it supplies an accessible name as a string (or null), when to use it for icon-only controls, and how to get or set it from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String or null

03

Purpose

Accessible name

04

Reflects

aria-label

05

Status

Baseline widely

06

Best for

Icon-only controls

Introduction

Every interactive control needs an accessible name. A button that only shows X may be clear visually, but a screen reader needs a spoken name like “Close” or “Close dialog”.

aria-label provides that name as a string. ariaLabel is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("close-button");
console.log(el.ariaLabel); // "Close"
el.ariaLabel = "Close dialog";
💡
Beginner tip

Prefer visible text or a <label> when you can. Use aria-label when the visible content is not a good name (icons, symbols, empty regions). Keep the string short and accurate.

Understanding the Property

MDN: the ariaLabel property of the Element interface reflects the value of the aria-label attribute, which defines a string value that labels the current element.

  • Reflected attribute — mirrors aria-label.
  • Get / set — readable and writable string (or null).
  • Accessible name — helps AT announce what the control is.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaLabel

Value

A string or null.

SituationTypical result
aria-label="Close""Close"
Attribute omittednull in many browsers
Assign a new stringUpdates the reflected attribute
⚠️
Naming tip

If a control already has clear visible text, duplicating it with aria-label is usually unnecessary. For icon-only UI, a concise label is essential.

📋 MDN Example Shape

MDN starts with aria-label="Close" on an icon-style button, then updates it to "Close dialog":

JavaScript
<button aria-label="Close" id="close-button">X</button>
JavaScript
let el = document.getElementById("close-button");
console.log(el.ariaLabel); // "Close"
el.ariaLabel = "Close dialog";
console.log(el.ariaLabel); // "Close dialog"

⚡ Quick Reference

GoalCode / note
Readel.ariaLabel
Set nameel.ariaLabel = "Close dialog"
Missing attributeOften null
Prefer whenIcon-only or unclear visible text
Prefer insteadVisible <label> / clear button text when possible
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaLabel.

Kind
get / set

Instance

Type
string | null

Accessible name

Reflects
aria-label

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaLabel. Labs use a close-button style control so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s update.

Example 1 — Read ariaLabel

Log the accessible name from a close button.

JavaScript
const el = document.getElementById("close-button");
console.log(el.ariaLabel);

// HTML includes: aria-label="Close"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "Close dialog"

MDN: make the accessible name more specific.

JavaScript
let el = document.getElementById("close-button");
console.log(el.ariaLabel); // "Close"
el.ariaLabel = "Close dialog";
console.log(el.ariaLabel); // "Close dialog"
Try It Yourself

How It Works

Assigning the property updates the reflected aria-label attribute so assistive technologies announce the new name.

📈 Icon Button Label, Attribute Sync & Snapshot

Practice naming controls and verify reflection.

Example 3 — Label a Menu Button

Create an icon-only button and set ariaLabel.

JavaScript
const btn = document.createElement("button");
btn.textContent = "☰";
document.body.appendChild(btn);

btn.ariaLabel = "Open menu";
console.log({
  ariaLabel: btn.ariaLabel,
  attr: btn.getAttribute("aria-label")
});
Try It Yourself

How It Works

The visible glyph stays for sighted users; the string becomes the accessible name for AT.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("button");
el.textContent = "X";
el.setAttribute("aria-label", "Close");
document.body.appendChild(el);

el.ariaLabel = "Close dialog";
console.log({
  fromProperty: el.ariaLabel,
  fromAttribute: el.getAttribute("aria-label"),
  same: el.ariaLabel === el.getAttribute("aria-label")
});
Try It Yourself

How It Works

Prefer ariaLabel in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and remember when to prefer visible labels.

JavaScript
console.log({
  supported: "ariaLabel" in Element.prototype,
  type: "string | null",
  tip: "Prefer visible labels; use aria-label for icon-only controls",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Use ariaLabel as a scripting-friendly way to keep accessible names in sync with UI state (for example switching between “Open menu” and “Close menu”).

🚀 Common Use Cases

  • Icon-only close, menu, search, or settings buttons.
  • Updating names when a control’s action changes (open ↔ close).
  • Naming landmark-like regions that lack a visible heading.
  • Giving meaningful names to custom widgets with sparse visible text.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Control needs an accessible name

Especially when visible text is missing or unclear.

Need
2

Set ariaLabel to a short string

The property reflects aria-label for get and set.

Name
3

Assistive tech uses that name

Users hear what the control does, not just “X” or “button”.

Announce
4

Icon UI stays usable for everyone

Sighted and AT users both understand the control.

📝 Notes

Browser Support

Element.ariaLabel is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.ariaLabel

String or null — reflects aria-label for an element's accessible name.

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaLabel IDL — use setAttribute
No
ariaLabel Baseline

Bottom line: Use ariaLabel to give controls a clear accessible name when visible text is missing or unclear. Keep strings short and accurate. Prefer visible labels when you can.

Conclusion

ariaLabel reflects aria-label so you can set a string accessible name from JavaScript. It shines on icon-only controls; when clear visible text exists, prefer that instead and keep names accurate.

Continue with ariaLabelledByElements, ariaBrailleLabel, EventTarget, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Label icon-only buttons clearly
  • Keep names short and action-focused
  • Update the label when the action changes
  • Prefer visible <label> / text when possible
  • Test names with a screen reader

❌ Don’t

  • Leave icon-only controls unnamed
  • Write long sentences into aria-label
  • Duplicate clear visible text unnecessarily
  • Use vague names like “button” or “click here”
  • Forget translated labels in multilingual UIs

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaLabel

Reflected aria-label string for an element's accessible name.

5
Core concepts
📝 02

string | null

accessible name

Type
🔍 03

Icon-only UI

common use case

When
04

Baseline

widely available

Status
🎯 05

Prefer visible

when text exists

Rule

❓ Frequently Asked Questions

It reflects the aria-label attribute as a string (or null), which defines a string value that labels the current element for assistive technologies.
No. MDN marks Element.ariaLabel as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string or null. When the attribute is missing, many browsers return null.
Use it when a control has no clear visible text name—for example an icon-only button like "X" for close. Prefer a visible <label> or aria-labelledby when a visible name already exists.
For many elements, aria-label becomes the accessible name and can override text content for assistive technologies. Keep the label accurate and concise.
Yes. Reading and writing ariaLabel updates the reflected aria-label attribute.
Did you know?

aria-label and aria-labelledby both contribute to accessible names, but they work differently: one embeds the name string on the element, the other points to visible text elsewhere in the page. Prefer aria-labelledby when the name already exists on screen.

Next: Element ariaLabelledByElements

Learn the reflected element array for aria-labelledby accessible names.

ariaLabelledByElements →

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