HTML: the aria-selected attribute

The aria-selected attribute tells assistive technology which item is selected in a widget such as a tab list or listbox.

What you will learn

Tabs example

<div role="tablist" aria-label="Account settings">
  <button role="tab" aria-selected="true" aria-controls="profile-panel">
    Profile
  </button>
  <button role="tab" aria-selected="false" aria-controls="security-panel">
    Security
  </button>
</div>

Only the active tab should normally have aria-selected="true". The script must update the selected state, focus behavior, and visible panel together.

Use the right state

Common mistakes