JavaScript Element ariaPosInSet Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

In JavaScript, ariaPosInSet reflects the aria-posinset attribute: a string integer for an element’s position in a set of listitems or treeitems (MDN) — especially when not all items are in the DOM.

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use el.ariaPosInSet. Start with this line.

JavaScript
element.ariaPosInSet
CallWhat it does
element.ariaPosInSetPrimary signature.

Built into the browser. Read or assign el.ariaPosInSet — no import required.

Library declarations
JavaScript
element.ariaPosInSet

Parameters

ParameterDescription
ValueOptional. String integer ≥ 1
aria-setsizeRequired. Full set size, or -1
Custom elementsOptional. ElementInternals.ariaPosInSet

Return Value

Return ValueDescription
*The current value of el.ariaPosInSet.

JavaScript Examples

Example 1 — Get and Set (MDN)

Read the current position, then update it to "3".

JavaScript
let el = document.getElementById("article2");
console.log(el.ariaPosInSet); // "2"
el.ariaPosInSet = "3";
console.log(el.ariaPosInSet); // "3"
Try It Yourself

How It Works

  1. Select the item. It already has aria-posinset="2".
  2. Read ariaPosInSet. Returns the string "2".
  3. Assign "3". Updates the reflected attribute.
  4. Read again. Confirms the new position in the set.

Example 2 — Pair with ariaSetSize

Announce “item N of M” for a partial option list.

JavaScript
const opt = document.getElementById("sodium");
opt.setAttribute("role", "option");
opt.ariaPosInSet = "11";
opt.ariaSetSize = "118";
console.log(opt.ariaPosInSet, opt.ariaSetSize);
Try It Yourself

How It Works

  1. Set the role. option (or another set item role).
  2. Set position. Absolute index in the full set as a string.
  3. Set size. Total count (here 118), even if few options are rendered.
  4. AT can announce something like position 11 of 118.

Example 3 — Property Reflects the Attribute

Show that ariaPosInSet and aria-posinset stay in sync.

JavaScript
const el = document.getElementById("article2");
el.ariaPosInSet = "4";
console.log(el.getAttribute("aria-posinset")); // "4"
el.setAttribute("aria-posinset", "2");
console.log(el.ariaPosInSet); // "2"
Try It Yourself

How It Works

  1. Write via the property. Attribute updates immediately.
  2. Read via getAttribute. Same value as ariaPosInSet.
  3. Write via the attribute. Property reflects the change.
  4. Use digit strings such as "2", not bare numbers for attribute intent.

Browser Support

Element.ariaPosInSet is marked Baseline Widely available on MDN (since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

✓ Baseline · Widely available

Element ariaPosInSet

Reflects aria-posinset — position within a set of items.

Widely Available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer No Element.ariaPosInSet
Not supported
ariaPosInSet Baseline support

Bottom line: Safe in modern browsers. Use with aria-setsize when only a subset of items is in the DOM. See the MDN Element.ariaPosInSet reference.

Frequently Asked Questions

It reflects the aria-posinset attribute as a string containing an integer — the element's number or position in the current set of listitems or treeitems.
No. MDN marks Element.ariaPosInSet as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
Use aria-posinset together with aria-setsize on each item in the set. ariaPosInSet is the position; ariaSetSize (or aria-setsize) is the total count in the set.
The property is a string containing an integer (for example "2" or "3"), not a JavaScript number type.
MDN reads aria-posinset="2" from article2 via ariaPosInSet, then assigns "3" to update the reflected attribute.
When not all items in a set are present in the DOM (for example a virtualized list). If every item is in the DOM, the browser can usually calculate position and aria-posinset is unnecessary.

Next: Element ariaPressed

Learn how toggle buttons expose pressed state to assistive technology.

ariaPressed tutorial →

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.

11 people found this page helpful