JavaScript Element ariaExpanded Property

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

What You’ll Learn

Element.ariaExpanded is an instance property that reflects the aria-expanded attribute. Learn the true, false, and undefined tokens, how they mark open or closed related content, and how to get or set the property from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String

03

Values

true · false · undefined

04

Reflects

aria-expanded

05

Status

Baseline widely

06

Used on

Combobox · disclosure · menu

Introduction

Many widgets open and close related content: a disclosure button, an accordion section, a combobox list, or a menu. Assistive technologies need to know whether that content is currently expanded or collapsed.

aria-expanded carries that signal. ariaExpanded is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("animal");
console.log(el.ariaExpanded); // "false"
el.ariaExpanded = "true";
💡
Beginner tip

Update ariaExpanded whenever you show or hide the controlled content. Pair it with aria-controls / ariaControlsElements so AT knows what is expanded.

Understanding the Property

MDN: the ariaExpanded property of the Element interface reflects the value of the aria-expanded attribute, which indicates whether a grouping element owned or controlled by this element is expanded or collapsed.

  • Reflected attribute — mirrors aria-expanded.
  • Get / set — readable and writable string.
  • Three tokenstrue, false, undefined.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaExpanded

Value

A string with one of the following values:

ValueMeaning (MDN)
"true"The grouping element this element owns or controls is expanded.
"false"The grouping element this element owns or controls is collapsed.
"undefined"The element does not own or control a grouping element that is expandable.

📋 Combobox (MDN Shape)

MDN shows a combobox that starts collapsed (aria-expanded="false"), then opens by setting ariaExpanded to "true":

JavaScript
<div class="animals-combobox">
  <label for="animal">Animal</label>
  <input
    id="animal"
    type="text"
    role="combobox"
    aria-autocomplete="list"
    aria-expanded="false"
    aria-haspopup="true" />
  <button id="animals-button" tabindex="-1" aria-label="Open">&#9661;</button>
  <ul id="animals-listbox" role="listbox" aria-label="Animals">
    <li id="animal-cat" role="option">Cat</li>
    <li id="animal-dog" role="option">Dog</li>
  </ul>
</div>
JavaScript
let el = document.getElementById("animal");
console.log(el.ariaExpanded); // false
el.ariaExpanded = "true";
console.log(el.ariaExpanded); // true

Also show or hide the listbox in the UI so sighted users and assistive tech stay aligned.

⚡ Quick Reference

GoalCode / note
Readel.ariaExpanded
Expandel.ariaExpanded = "true"
Collapseel.ariaExpanded = "false"
Not expandableel.ariaExpanded = "undefined"
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaExpanded.

Kind
get / set

Instance

Type
string

3 tokens

Reflects
aria-expanded

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaExpanded. Labs use a combobox-style input so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s expand update.

Example 1 — Read ariaExpanded

Log the current expanded state from a combobox.

JavaScript
const el = document.getElementById("animal");
console.log(el.ariaExpanded);

// HTML includes: aria-expanded="false"
Try It Yourself

How It Works

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

Example 2 — MDN Expand to "true"

MDN: change from collapsed to expanded.

JavaScript
let el = document.getElementById("animal");
console.log(el.ariaExpanded); // false
el.ariaExpanded = "true";
console.log(el.ariaExpanded); // true
Try It Yourself

How It Works

Assigning the property updates the reflected aria-expanded attribute so assistive technologies hear the new open/closed state.

📈 Toggle, Attribute Sync & Snapshot

Practice open/close cycles and verify reflection.

Example 3 — Toggle Expanded State

Flip between "true" and "false".

JavaScript
const el = document.getElementById("animal");

function setExpanded(open) {
  el.ariaExpanded = open ? "true" : "false";
  // Also show/hide the listbox (or panel) in the UI
}

setExpanded(true);
console.log("after open:", el.ariaExpanded);
setExpanded(false);
console.log("after close:", el.ariaExpanded);
Try It Yourself

How It Works

Keep the visible popup or panel in sync with the string you set—ARIA alone does not show or hide content.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("button");
el.setAttribute("aria-expanded", "false");
document.body.appendChild(el);

el.ariaExpanded = "true";
console.log({
  fromProperty: el.ariaExpanded,
  fromAttribute: el.getAttribute("aria-expanded"),
  same: el.ariaExpanded === el.getAttribute("aria-expanded")
});
Try It Yourself

How It Works

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

Example 5 — Support Snapshot

Feature-detect and list the allowed tokens.

JavaScript
console.log({
  supported: "ariaExpanded" in Element.prototype,
  allowed: ["true", "false", "undefined"],
  tip: "Sync UI show/hide with ariaExpanded on every toggle",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

The string "undefined" is a real ARIA token meaning “not expandable”—it is not the same as a missing attribute returning JavaScript null.

🚀 Common Use Cases

  • Comboboxes and autocomplete popups.
  • Disclosure / accordion headers that show or hide panels.
  • Menus, listboxes, and tree expanders.
  • Keeping script and markup aligned without manual setAttribute.
  • Pairing with aria-controls / ariaControlsElements.

🔧 How It Works

1

User opens or closes the widget

Click, Enter, Space, Escape, or arrow keys.

Input
2

Script updates ariaExpanded

Set "true" or "false".

State
3

UI shows or hides controlled content

Listbox, panel, or menu visibility matches the token.

UI
4

Assistive tech announces expanded / collapsed

Screen readers report the open or closed state.

📝 Notes

Browser Support

Element.ariaExpanded 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.ariaExpanded

String true / false / undefined — reflects aria-expanded.

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 ariaExpanded IDL — use setAttribute
No
ariaExpanded Baseline

Bottom line: Use ariaExpanded to get/set aria-expanded on disclosures, comboboxes, menus, and similar widgets. Keep UI visibility in sync. Pair with aria-controls when you point to controlled content.

Conclusion

ariaExpanded reflects aria-expanded so expandable controls can expose open, closed, or non-expandable states. Update the property whenever the UI opens or closes, and keep controlled content visibility aligned.

Continue with ariaFlowToElements, ariaControlsElements, EventTarget, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use string tokens: true / false / undefined
  • Update on every open and close
  • Show or hide controlled content in the same step
  • Pair with aria-controls when useful
  • Support keyboard open/close (Enter, Space, Escape)

❌ Don’t

  • Leave the UI open while ariaExpanded stays "false"
  • Assign boolean true / false expecting ARIA strings
  • Use "undefined" as a fancy closed style
  • Forget Escape to collapse popups
  • Skip an accessible name on the control

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaExpanded

Reflected aria-expanded string for open/closed controlled content.

5
Core concepts
📝 02

Three values

true false undefined

Tokens
🔍 03

Combobox & more

disclosure · menu

Use
04

Baseline

widely available

Status
🎯 05

Sync UI

show / hide content

Rule

❓ Frequently Asked Questions

It reflects the aria-expanded attribute as a string, indicating whether a grouping element owned or controlled by this element is expanded or collapsed.
No. MDN marks Element.ariaExpanded as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
The strings "true" (expanded), "false" (collapsed), or "undefined" (does not own or control an expandable grouping).
In JavaScript you assign the strings "true", "false", and "undefined", not boolean or JavaScript undefined alone. The property reflects the ARIA attribute value.
On controls that open or close related content: disclosures, accordions, comboboxes, menus, tree nodes, and similar widgets. Keep the visible open/close state in sync.
ariaExpanded says whether the controlled content is open. ariaControlsElements (or aria-controls) points to which elements are controlled.
Did you know?

The FAQ accordion on this page uses aria-expanded on each question button so screen readers know whether an answer panel is open—the same idea you just learned.

Next: Element ariaFlowToElements

Learn the reflected aria-flowto element-array property for alternate reading order.

ariaFlowToElements →

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