JavaScript Element ariaSelected Property

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

What You’ll Learn

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

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.

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 tokenstrue, false, undefined.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaSelected

Value

A string with one of the following values:

ValueMeaning (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.

📋 MDN Tab Example Shape

MDN starts with a tab marked aria-selected="true", then updates it to "false" with the property:

JavaScript
<button role="tab" aria-selected="true" aria-controls="tabpanel-id" id="tab-id">
  Tab label
</button>
JavaScript
let el = document.getElementById("tab-id");
console.log(el.ariaSelected); // "true"
el.ariaSelected = "false";
console.log(el.ariaSelected); // "false"

Related learning: ariaMultiSelectable (whether a container allows multiple selections) and ariaControlsElements (which panel a tab controls).

⚡ Quick Reference

GoalCode / note
Readel.ariaSelected
Selectel.ariaSelected = "true"
Deselectel.ariaSelected = "false"
Not selectableel.ariaSelected = "undefined"
Common rolestab, option, row, treeitem
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaSelected.

Kind
get / set

Instance

Type
string

3 tokens

Reflects
aria-selected

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaSelected. Labs use a role="tab" control so you can safely read and write the property.

📚 Getting Started

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

Example 1 — Read ariaSelected

Log the current selected state from a tab.

JavaScript
const el = document.getElementById("tab-id");
console.log(el.ariaSelected);

// HTML includes: role="tab" aria-selected="true"
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 "false"

MDN: change from selected to not selected.

JavaScript
let el = document.getElementById("tab-id");
console.log(el.ariaSelected); // "true"
el.ariaSelected = "false";
console.log(el.ariaSelected); // "false"
Try It Yourself

How It Works

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.

Example 3 — Set "undefined"

Mark an item as not selectable.

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "option");
el.setAttribute("aria-selected", "false");
el.textContent = "Disabled choice";
document.body.appendChild(el);

el.ariaSelected = "undefined";
console.log({
  ariaSelected: el.ariaSelected,
  attr: el.getAttribute("aria-selected")
});
Try It Yourself

How It Works

"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.

JavaScript
const el = document.createElement("button");
el.setAttribute("role", "tab");
el.setAttribute("aria-selected", "true");
el.textContent = "Tab label";
document.body.appendChild(el);

el.ariaSelected = "false";
console.log({
  fromProperty: el.ariaSelected,
  fromAttribute: el.getAttribute("aria-selected"),
  same: el.ariaSelected === el.getAttribute("aria-selected")
});
Try It Yourself

How It Works

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)"
});
Try It Yourself

How It Works

Do not let ARIA selection disagree with the visible active tab or highlighted option—mismatched selection confuses AT users.

🚀 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.

🔧 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.

📝 Notes

Browser Support

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

String — reflects aria-selected (true / false / undefined).

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

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.

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.

Continue with ariaSetSize, ariaMultiSelectable, ariaPressed, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use string tokens true / false / undefined
  • Match ARIA selection to the visible active item
  • Update sibling tabs when selection changes
  • Wire keyboard selection for custom widgets
  • Pair tabs with panels via aria-controls

❌ Don’t

  • Leave selection out of sync with the UI
  • Treat the value as a Boolean type in ARIA APIs
  • Confuse selected with checked or pressed
  • Mark non-selectable items as false when they should be undefined
  • Forget to deselect the previous single-select item

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaSelected

Reflected aria-selected string for which item is selected.

5
Core concepts
📝 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.

Next: Element ariaSetSize

Learn the reflected aria-setsize property for the total count in a set.

ariaSetSize →

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