[aria-activedescendant]
Example
<ul role="listbox" aria-activedescendant="opt2">
<li id="opt1" role="option">Apple</li>
<li id="opt2" role="option">Pear</li>
</ul><ul role="listbox" tabindex="0" aria-label="Fruit" aria-activedescendant="opt2">
<li id="opt1" role="option">Apple</li>
<li id="opt2" role="option" class="active">Pear</li>
</ul>The listbox can take focus and has a name, and the active option is styled, so the virtual focus is usable.
Common mistakes
- Setting
aria-activedescendanton a<div>withouttabindex, so it never gets focus. - Pointing at an ID that was removed after filtering, so nothing is announced.
Key points
- DOM focus stays on the container or input, which is focusable and has a composite role.
- The referenced ID points to an existing descendant or owned element with a role like
option. - Arrow keys update
aria-activedescendantand the active item is visually highlighted and scrolled into view.
Interview questions
aria-activedescendant vs roving tabindex: which is better?
Both work. Roving tabindex moves real focus and is widely supported. aria-activedescendant suits comboboxes where focus must stay in the input.
Does aria-activedescendant fire focus events on the item?
No. The item never gets DOM focus, so :focus styles and focus events do not apply; style it with a class.