Element.ariaSelected is an instance property that reflects the aria-selected attribute. Learn the true, false, and undefined values, how tabs and options use selection, 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-selected
05
Status
Baseline widely
06
Used on
Tab · option · more
Fundamentals
Introduction
Tabs, listbox options, grid rows, and tree items often have a selected state—the active tab, the chosen option, or the highlighted row. Assistive technologies need that signal to announce what is currently selected.
aria-selected carries that signal. ariaSelected is the JavaScript reflection of that attribute.
JavaScript
const el = document.getElementById("tab-id");
console.log(el.ariaSelected); // "true"
el.ariaSelected = "false";
💡
Beginner tip
In a tablist, usually only one tab has aria-selected="true" at a time. Pair the selected tab with the visible tab panel via aria-controls, and keep keyboard arrow navigation in sync.
Concept
Understanding the Property
MDN: the ariaSelected property of the Element interface reflects the value of the aria-selected attribute, which indicates the current “selected” state of elements that have a selected state.
Reflected attribute — mirrors aria-selected.
Get / set — readable and writable string.
Three tokens — true, false, undefined.
Baseline — widely available since October 2023 (MDN).
Foundation
📝 Syntax
JavaScript
ariaSelected
Value
A string with one of the following values:
Value
Meaning (MDN)
"true"
The item is selected.
"false"
The item is not selected.
"undefined"
The item is not selectable.
⚠️
Selected vs checked vs pressed
Use ariaSelected for selection in tabs, listboxes, grids, and trees. Use ariaChecked for checkboxes/radios, and ariaPressed for toggle buttons.
Pattern
📋 MDN Tab Example Shape
MDN starts with a tab marked aria-selected="true", then updates it to "false" with the property:
Assigning the property updates the reflected aria-selected attribute so assistive technologies hear the new selection state. In a real tablist, also select another tab and show its panel.
📈 Undefined, Attribute Sync & Snapshot
Practice non-selectable items and verify reflection.
"undefined" means the item is not selectable—different from "false", which means selectable but currently not selected. Also remove the item from keyboard selection paths when it is not selectable.
Example 4 — Property vs getAttribute
Confirm the attribute stays in sync after a write.
Prefer ariaSelected in script; keep the attribute for HTML markup.
Example 5 — Support Snapshot
Feature-detect and list the allowed tokens.
JavaScript
console.log({
supported: "ariaSelected" in Element.prototype,
allowed: ["true", "false", "undefined"],
tip: "Keep only one tab selected in a single-select tablist",
status: "Baseline Widely available (MDN)"
});
{
"supported": true,
"allowed": ["true", "false", "undefined"],
"tip": "Keep only one tab selected in a single-select tablist",
"status": "Baseline Widely available (MDN)"
}
How It Works
Do not let ARIA selection disagree with the visible active tab or highlighted option—mismatched selection confuses AT users.
Applications
🚀 Common Use Cases
Marking the active tab in a custom tablist.
Showing which options are selected in a listbox or combobox.
Highlighting selected rows or cells in an ARIA grid.
Updating selection when the user presses arrow keys or clicks.
Keeping script and markup aligned without manual setAttribute.
Under the Hood
🔧 How It Works
1
User picks an item
Click, Space, Enter, or arrow keys.
Input
2
ariaSelected updates
Set true on the chosen item; false on others.
State
3
UI matches selection
Show the active tab panel or highlight.
UI
4
✓
Assistive tech announces selection
Users hear which item is selected.
Important
📝 Notes
Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
Value is a string: true, false, or undefined.
Prefer native controls (for example <select>) when they fit the UI.
Element.ariaSelected is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.
Internet ExplorerNo ariaSelected IDL — use setAttribute
No
ariaSelectedBaseline
Bottom line: Use ariaSelected to get/set aria-selected on tabs, options, and other selectable items. Keep visuals and keyboard behavior in sync. Pair with ariaMultiSelectable when the container allows multiple selections.
Wrap Up
Conclusion
ariaSelected reflects aria-selected so selectable widgets can declare which item is selected. Use the string tokens, keep UI in sync, and prefer native selection controls when they are enough.
Mark non-selectable items as false when they should be undefined
Forget to deselect the previous single-select item
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about ariaSelected
Reflected aria-selected string for which item is selected.
5
Core concepts
📄01
Get / set
on Element
Kind
📝02
String tokens
true / false / undefined
Type
🔍03
Tab · option
selectable widgets
Use
✅04
Baseline
widely available
Status
🎯05
vs checked
selection ≠ checked
Tip
❓ Frequently Asked Questions
It reflects the aria-selected attribute as a string that indicates the current selected state of elements that can be selected (for example tabs, options, gridcells, or tree items).
No. MDN marks Element.ariaSelected as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
One of the strings "true" (selected), "false" (not selected), or "undefined" (not selectable).
Often role="tab", role="option", gridcell, row, or treeitem — any widget that has a selected state in the ARIA model.
ariaSelected marks selection in lists, tabs, and grids. ariaChecked is for checked widgets (checkbox/radio). ariaPressed is for toggle buttons that stay pressed or unpressed.
Yes. Reading and writing ariaSelected updates the reflected aria-selected attribute.
Did you know?
MDN’s demo uses a real <button role="tab"> with aria-controls—so the tab both looks like a control and points to its panel while ariaSelected tracks selection.