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
Fundamentals
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.
Concept
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 tokens — true, false, undefined.
Baseline — widely available since October 2023 (MDN).
Foundation
📝 Syntax
JavaScript
ariaExpanded
Value
A string with one of the following values:
Value
Meaning (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.
Pattern
📋 Combobox (MDN Shape)
MDN shows a combobox that starts collapsed (aria-expanded="false"), then opens by setting ariaExpanded to "true":
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);
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)"
});
Element.ariaExpanded is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.
Internet ExplorerNo ariaExpanded IDL — use setAttribute
No
ariaExpandedBaseline
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.
Wrap Up
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.
Reflected aria-expanded string for open/closed controlled content.
5
Core concepts
📄01
Get / set
on Element
Kind
📝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.