JavaScript Element ariaSetSize Property

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

What You’ll Learn

Element.ariaSetSize is an instance property that reflects the aria-setsize attribute. Learn how it declares the total number of items in a set, how it pairs with ariaPosInSet, and how to get or set it from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String (integer)

03

Meaning

Total items in set

04

Reflects

aria-setsize

05

Status

Baseline widely

06

Pairs with

ariaPosInSet

Introduction

Screen readers often announce “item 2 of 5” or “tab 1 of 3.” The “of N” part is the set size—how many items belong to the group.

aria-setsize declares that total. The DOM property ariaSetSize lets you read and update it from JavaScript.

JavaScript
const el = document.getElementById("tab-id");
console.log(el.ariaSetSize); // "3"
el.ariaSetSize = "4";
💡
Beginner tip

Prefer native lists (<ul> / <ol>) when the DOM already expresses order and size. Use ariaSetSize for custom widgets, tabs, trees, or virtualized sets where not every item is in the DOM.

Understanding the Property

MDN: the ariaSetSize property of the Element interface reflects the value of the aria-setsize attribute, which defines the number of items in the current set of listitems or treeitems.

  • Reflected attribute — mirrors aria-setsize.
  • Get / set — readable and writable string integer.
  • Total count — how many items belong to the set.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaSetSize

Value

A string which contains an integer (the number of items in the set).

ItemDetail
Typestring containing an integer (e.g. "3")
Reflectsaria-setsize
Applies tolistitem, treeitem, tab, and similar set members
Pair witharia-posinset / ariaPosInSet
⚠️
Position + total

ariaPosInSet is “which number am I?” ariaSetSize is “how many are there?” Set both on each item for clear “N of M” announcements.

📋 MDN Tab Example Shape

MDN starts with a tab marked aria-setsize="3" (three tabs in the group), then updates ariaSetSize to "4":

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

When you add or remove tabs, update ariaSetSize on every tab in the set (and keep each ariaPosInSet accurate).

⚡ Quick Reference

GoalCode / note
Readel.ariaSetSize
Writeel.ariaSetSize = "4"
HTML attributearia-setsize="3"
Pair withel.ariaPosInSet = "1"
Prefer native<ul> / <ol> when possible
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaSetSize.

Kind
get / set

Instance

Type
string

Integer text

Reflects
aria-setsize

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaSetSize. Labs use a tab with aria-setsize so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s set-size update.

Example 1 — Read ariaSetSize

Log the total set size from a tab.

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

// HTML includes: aria-setsize="3"
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 "4"

MDN: change the set size from 3 to 4 (a fourth tab was added).

JavaScript
let el = document.getElementById("tab-id");
console.log(el.ariaSetSize); // "3"
el.ariaSetSize = "4";
console.log(el.ariaSetSize); // "4"
Try It Yourself

How It Works

Assigning the property updates the reflected aria-setsize attribute. In a real tablist, update every tab—not only the active one.

📈 PosInSet Pair, Attribute Sync & Snapshot

Practice pairing with position and verify reflection.

Example 3 — Pair with ariaPosInSet

Declare position and total so AT can announce “2 of 5.”

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "listitem");
el.textContent = "Second item";
document.body.appendChild(el);

el.ariaPosInSet = "2";
el.ariaSetSize = "5";
console.log({
  position: el.ariaPosInSet,
  total: el.ariaSetSize,
  spokenLike: "item 2 of 5"
});
Try It Yourself

How It Works

Keep ariaPosInSet within 1..ariaSetSize. When the set grows or shrinks, update both properties on every member.

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-setsize", "3");
el.textContent = "Tab label";
document.body.appendChild(el);

el.ariaSetSize = "4";
console.log({
  fromProperty: el.ariaSetSize,
  fromAttribute: el.getAttribute("aria-setsize"),
  same: el.ariaSetSize === el.getAttribute("aria-setsize")
});
Try It Yourself

How It Works

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

Example 5 — Support Snapshot

Feature-detect and remember the position + total pair.

JavaScript
console.log({
  supported: "ariaSetSize" in Element.prototype,
  pairWith: "ariaPosInSet / aria-posinset",
  valueType: "string integer",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Do not leave set size stale after items are added or removed—mismatched totals confuse AT users.

🚀 Common Use Cases

  • Announcing how many tabs are in a custom tablist.
  • Virtualized lists where only a window of items is in the DOM.
  • Custom listitem / treeitem sets without native <ul> order.
  • Updating totals when users add or remove items dynamically.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Define the set

Tabs, listitems, or treeitems that belong together.

Group
2

ariaSetSize sets the total

How many items are in the set.

Total
3

ariaPosInSet sets the place

Which number this item is within that total.

Index
4

Assistive tech says “N of M”

Users hear position and set size together.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Value is a string containing an integer.
  • Prefer native lists when they already express size and order.
  • Related: ariaSelected, ariaPosInSet, ariaSort, JavaScript hub.

Browser Support

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

String integer — reflects aria-setsize (total items in the set).

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

Bottom line: Use ariaSetSize to get/set aria-setsize. Pair with ariaPosInSet for clear N-of-M announcements. Prefer native HTML lists when you can. Keep the value as a string integer such as "3" or "4".

Conclusion

ariaSetSize reflects aria-setsize so set members can declare how many items belong to the group. Use string integers, pair with ariaPosInSet, and prefer native lists when that is enough.

Continue with ariaSort, ariaPosInSet, ariaSelected, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use string integers for the total count
  • Set ariaSetSize on every item in the set
  • Pair with ariaPosInSet for position
  • Update size when items are added or removed
  • Prefer native <ul> / <ol> when possible

❌ Don’t

  • Leave set size stale after DOM changes
  • Treat the value as a Number type in ARIA APIs
  • Use aria-setsize without aria-posinset on set members
  • Put different totals on siblings in the same set
  • Rebuild native lists with ARIA without need

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaSetSize

Reflected aria-setsize string for how many items are in the set.

5
Core concepts
📝 02

String integer

total count

Type
🔍 03

List · tab · tree

set members

Use
04

Baseline

widely available

Status
🎯 05

+ posinset

N of M pair

Tip

❓ Frequently Asked Questions

It reflects the aria-setsize attribute as a string containing an integer that defines the number of items in the current set of listitems or treeitems (and similar sets such as tabs).
No. MDN marks Element.ariaSetSize as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string that contains an integer (for example "3" or "4"), not a Number type.
Use aria-setsize together with aria-posinset on each item. ariaSetSize is the total count; ariaPosInSet is the item’s position in that set.
When the full set is not all in the DOM at once (virtualized lists) or when custom widgets are not native lists, so assistive technologies still know the total size.
Yes. Reading and writing ariaSetSize updates the reflected aria-setsize attribute.
Did you know?

MDN’s demo puts aria-setsize on a selected tab with aria-controls—so AT learns both selection and how many tabs exist in the group.

Next: Element ariaSort

Learn the reflected aria-sort property for table and grid column sort direction.

ariaSort →

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