The HTML aria-setsize attribute
The aria-setsize attribute states the total number of items in a set (a list, listbox, menu or tree) when the DOM contains only some of them. Pair it with aria-posinset so screen readers can say "item 5 of 200".
Overview
The aria-setsize attribute defines the total number of items in a set when not all are in the DOM.
It describes an element's place in a larger set or hierarchy. This matters when not all items are present in the DOM at once: a virtualized list or a lazy-loaded tree, so assistive technology cannot count them itself. For fully-rendered native lists, the browser computes position and size for you.
Like all ARIA, aria-setsize changes only the accessibility tree (what assistive technology perceives), never the element's behavior or appearance. The first rule of ARIA applies: if a native HTML element or attribute conveys this, use that instead, and only reach for ARIA when nothing native fits.
Syntax
<li role="option" aria-setsize="200" aria-posinset="5"> … </li>
Values
| Value |
|---|
| An integer (use -1 if the total is unknown). |
Example
<li role="option" aria-setsize="200" aria-posinset="5">Item</li>
Best practices
- In a
role="feed", aria-setsize can go on each <article>. It may hold the real total when the supply of articles is fixed, or -1 when that total is very large, open-ended or changes often. - Every member of one set carries the same total. In a tree, each group of sibling treeitems is a set of its own, so a branch's children report their own count rather than the size of the whole tree.
- Rewrite the value on every loaded item when the total changes, such as after a filter narrows the list. The number must equal the count of items in the whole set.
- In a menu, count the menuitem, menuitemcheckbox and menuitemradio elements and leave separators out of the total.
- Native <option> elements in a <select> and radio buttons that share a name need no aria-setsize, since the browser already counts them as it counts list items.























