[aria-setsize]

Term side of the Card.
Topic: Relationship Attributes
Unit title: [aria-setsize]
Categories: Attribute
Explanation side of the Card

Explanation: The attribute that specifies the total number of items in a set, such as a list or menu. It helps users understand the size of the set and the number of items it contains.

Example

Wronghtml
<ul role="listbox">
  <li role="option">Item 501</li>
  <li role="option">Item 502</li>
</ul>
Righthtml
<ul role="listbox">
  <li role="option" aria-setsize="1000" aria-posinset="501">Item 501</li>
  <li role="option" aria-setsize="1000" aria-posinset="502">Item 502</li>
</ul>

With only part of the list rendered, these attributes give the real position and size.

Common mistakes

  • A virtualized list announced as '1 of 20' when it has 10,000 items.

Key points

  • aria-setsize is used only when not all items are in the DOM, like virtualized lists or feeds.
  • aria-setsize is '-1' when the total is unknown, not a guess.
  • Each item that has aria-setsize also has a matching aria-posinset.

Interview questions

Do I need aria-setsize on a normal list?

No. Browsers count the items when they are all in the DOM, so a plain <ul> already announces the size.

Which roles support aria-setsize?

Items like listitem, option, treeitem, menuitem, tab, radio, article and row in a treegrid.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy