JavaScript Element ariaPosInSet Property

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

What You’ll Learn

Element.ariaPosInSet is an instance property that reflects the aria-posinset attribute. Learn how it marks an item’s position in a set of listitems or treeitems, how to pair it with aria-setsize, and how to get or set the property from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String (integer)

03

Meaning

Position in set

04

Reflects

aria-posinset

05

Status

Baseline widely

06

Pair with

aria-setsize

Introduction

Screen readers often announce list position—“item 2 of 5”—when you move through a native <ul> or <ol>. Custom listitems may not expose that order unless you declare it.

aria-posinset marks an item’s position in the current set. ariaPosInSet is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("article2");
console.log(el.ariaPosInSet); // "2"
el.ariaPosInSet = "3";
💡
Beginner tip (MDN)

Prefer native lists when the DOM already expresses order. Use aria-posinset and aria-setsize on custom listitems or treeitems when assistive technology needs an explicit position in the set.

Understanding the Property

MDN: the ariaPosInSet property of the Element interface reflects the value of the aria-posinset attribute, which defines the element’s number or position in the current set of listitems or treeitems.

  • Reflected attribute — mirrors aria-posinset.
  • Get / set — readable and writable string containing an integer.
  • Pair witharia-setsize for total set size.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaPosInSet

Value

A string containing an integer.

ExampleMeaning
"1"First item in the set
"2"Second item in the set
"3"Third item, and so on
⚠️
Pair with aria-setsize

Set ariaPosInSet and ariaSetSize on each listitem or treeitem so assistive technology can announce “item 2 of 5.”

📋 MDN Example Shape

MDN starts with aria-posinset="2" on an article, then updates it to "3" with the property:

JavaScript
<article id="article1" aria-posinset="1">…</article>
<article id="article2" aria-posinset="2">…</article>
JavaScript
let el = document.getElementById("article2");
console.log(el.ariaPosInSet); // "2"
el.ariaPosInSet = "3";
console.log(el.ariaPosInSet); // "3"

⚡ Quick Reference

GoalCode / note
Readel.ariaPosInSet
Set positionel.ariaPosInSet = "2"
Value shapeString integer ("1", "2", …)
Prefer when possibleNative <ul> / <ol>
Common pairingaria-setsize / ariaSetSize
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaPosInSet.

Kind
get / set

Instance

Type
string

Integer text

Reflects
aria-posinset

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaPosInSet. Labs use article and role="listitem" elements so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s update.

Example 1 — Read ariaPosInSet

Log the position from an article in a set.

JavaScript
const el = document.getElementById("article2");
console.log(el.ariaPosInSet);

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

MDN: change the position from 2 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

Assigning the property updates the reflected aria-posinset attribute so assistive technologies hear the new position in the set.

📈 Listitem Role, Attribute Sync & Snapshot

Practice setting positions and verify reflection.

Example 3 — Set Position on a Listitem

Build a custom listitem and set ariaPosInSet to "2".

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({
  ariaPosInSet: el.ariaPosInSet,
  ariaSetSize: el.ariaSetSize,
  attr: el.getAttribute("aria-posinset")
});
Try It Yourself

How It Works

Pair ariaPosInSet with ariaSetSize so screen readers can announce “item 2 of 5.” Prefer <li> in real pages when you can.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("article");
el.setAttribute("aria-posinset", "1");
el.textContent = "First article";
document.body.appendChild(el);

el.ariaPosInSet = "2";
console.log({
  fromProperty: el.ariaPosInSet,
  fromAttribute: el.getAttribute("aria-posinset"),
  same: el.ariaPosInSet === el.getAttribute("aria-posinset")
});
Try It Yourself

How It Works

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

Example 5 — Support Snapshot

Feature-detect and remember the native-list preference.

JavaScript
console.log({
  supported: "ariaPosInSet" in Element.prototype,
  type: "string containing an integer",
  pairWith: "ariaSetSize / aria-setsize",
  tip: "Prefer native ul/ol when possible (MDN)",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Use ariaPosInSet when custom listitems or treeitems need explicit set position; otherwise lean on HTML list semantics.

🚀 Common Use Cases

  • Custom role="listitem" widgets that cannot use <li> in a native list.
  • Updating position when items are reordered in a virtual list or feed.
  • Tree items that expose position within a sibling group via aria-posinset.
  • Design-system components that render lists as non-list markup.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Element sits in a set

List of listitems, tree siblings, or similar grouped items.

Structure
2

Set ariaPosInSet to a string integer

The property reflects aria-posinset for get and set.

Declare
3

Assistive tech announces position

Users hear “item 2 of 5” when both position and set size are set.

Announce
4

Set order stays understandable

Especially when native list markup is unavailable.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Prefer native <ul> / <ol> when possible (MDN note).
  • Pair with aria-setsize on every item in the set.
  • Value is a string containing an integer, not a Number type.
  • Related: ariaPlaceholder, ariaPressed, ariaLabel, JavaScript hub.

Browser Support

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

String integer — reflects aria-posinset for position in a set of listitems or treeitems.

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

Bottom line: Use ariaPosInSet to declare position in a set for listitems and treeitems. Pair with ariaSetSize. Prefer native HTML lists when you can. Keep the value as a string integer such as "1" or "2".

Conclusion

ariaPosInSet reflects aria-posinset so list and tree widgets can expose their position in a set as a string integer. Reach for native lists first; use this property when custom listitems or treeitems need explicit set position.

Continue with ariaPressed, ariaPlaceholder, ariaLabel, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer <ul> / <ol> when possible
  • Use string integers like "1" and "2"
  • Set ariaSetSize on every item in the set
  • Keep positions consistent when items are reordered
  • Test list navigation with a screen reader

❌ Don’t

  • Skip native lists just to use ARIA
  • Assign mismatched position and set size (e.g. item 6 of 3)
  • Store a Number type and assume AT will coerce it
  • Use aria-posinset without aria-setsize on set members
  • Forget to update positions after drag-and-drop reorder

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaPosInSet

Reflected aria-posinset string for position in a set.

5
Core concepts
📝 02

String integer

"1" "2" "3"

Type
🔍 03

Prefer ul/ol

when possible

MDN
04

Baseline

widely available

Status
🎯 05

aria-setsize

pair on each item

Use

❓ 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 items are not in a native ordered list but assistive technology should still announce position (for example item 2 of 5). Prefer native ul/ol when the DOM already expresses order.
Did you know?

aria-posinset applies to listitems and treeitems in a set. Pair it with aria-setsize so assistive technology can announce both position and total count. Still start with the simplest native HTML that matches your structure.

Next: ariaPressed

Learn the reflected aria-pressed property for toggle button state.

ariaPressed →

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