How accessible is your website?Start free check
WCAG 4.1.2Level ARobust

Accessible Tabs: ARIA Roles and Arrow Keys

Also called: Accessible tab panel, ARIA tabs, Tab widget, Tablist

Definition

Accessible tabs are a tab interface whose tabs are exposed as a tab list with selected state, are operable with the keyboard and are connected to the panel they show. They fall under WCAG 4.1.2 Name, Role, Value at Level A, because custom tab widgets must tell assistive technology their role and state.

Accessible tabs are tab interfaces – product details, pricing tables, settings pages – that every visitor can use, not only people with a mouse. Many tab widgets are built from divs and click handlers: they look like tabs, but a screen reader announces plain text, the keyboard cannot reach them, and nobody hears which tab is open. A tab panel that is accessible needs the right roles, a selected state and a predictable keyboard pattern.

What it means

HTML has no native tab element, so every tab widget is a custom component. That puts it under WCAG 4.1.2 Name, Role, Value (Level A): for scripted components, the name, role and value must be programmatically determinable, and changes to states must be available to assistive technologies. The W3C Tabs Pattern of the ARIA Authoring Practices describes how:

Element Role and attributes
Container of the tabs role="tablist", a label via aria-label or aria-labelledby
Each tab role="tab", aria-selected="true" on the active one, false on the others, aria-controls pointing to its panel
Each panel role="tabpanel", aria-labelledby pointing to its tab
Vertical tab list aria-orientation="vertical" (horizontal is the default)

The keyboard pattern:

Key What happens
Tab Moves focus to the active tab, then out of the tab list into the panel
Left / Right Arrow Moves between tabs, wrapping from last to first
Home / End (optional) Jumps to the first or last tab
Enter / Space Activates the focused tab if tabs are not activated automatically

Only the active tab is in the Tab order (tabindex="0"), the others get tabindex="-1" – arrow keys move between them. This is the "roving tabindex" technique described in tabindex.

Examples

Example
<div role="tablist" aria-label="Product information">
  <button role="tab" id="tab-1" aria-selected="true"
          aria-controls="panel-1" tabindex="0">Description</button>
  <button role="tab" id="tab-2" aria-selected="false"
          aria-controls="panel-2" tabindex="-1">Sizes</button>
  <button role="tab" id="tab-3" aria-selected="false"
          aria-controls="panel-3" tabindex="-1">Reviews</button>
</div>

<div role="tabpanel" id="panel-1" aria-labelledby="tab-1" tabindex="0">
  <p>Hand-knitted wool scarf, 180 cm long.</p>
</div>
<div role="tabpanel" id="panel-2" aria-labelledby="tab-2" tabindex="0" hidden>…</div>
<div role="tabpanel" id="panel-3" aria-labelledby="tab-3" tabindex="0" hidden>…</div>

A screen reader now announces something like "Product information, tab list – Description, tab, selected, 1 of 3". The script switches aria-selected, tabindex and hidden when another tab is chosen. Using <button> elements gives the tabs a keyboard navigation baseline even before the script runs.

Do

Use tablist, tab and tabpanel, keep aria-selected in sync, support the arrow keys, keep a visible focus outline on the active tab, and give the tab list a label.

Don't

Build tabs from links that reload the page while pretending to be tabs, put role="tab" on a list item around the real link, leave every tab in the Tab order without arrow keys, or show the active tab only through color.

How to check accessible tabs

    Questions

    How do you make tabs accessible?

    Give the container role="tablist", each tab role="tab" with aria-selected and aria-controls, and each panel role="tabpanel". Then add arrow-key navigation and keep only the active tab in the Tab order.

    Should arrow keys or the Tab key switch tabs?

    Arrow keys move between tabs; the Tab key moves into and out of the tab list. That is the pattern in the W3C ARIA Authoring Practices and what screen reader users expect.

    Do tabs need aria-controls?

    The W3C pattern sets aria-controls on each tab, pointing to its panel, and aria-labelledby on the panel, pointing back to the tab. Together they tell assistive technology which tab shows which content.

    Are tabs bad for accessibility?

    Not if they follow the pattern. Problems come from custom widgets without roles and states. If the content is short, simple headings or an accordion can be easier for everyone.

    Which WCAG criterion applies to tabs?

    Mainly 4.1.2 Name, Role, Value, plus 2.1.1 Keyboard and 2.4.7 Focus Visible – all part of WCAG 2.2.

    • Name, Role, Value: Controls Screen Readers Understand

      Name, Role, Value is WCAG success criterion 4.1.2: for every user interface component, the name and role can be programmatically determined, user-settable states, properties and values can be programmatically set, and changes are announced to assistive technologies. It is Level A.

      Read definition: Name, Role, Value: Controls Screen Readers Understand
    • Keyboard Navigation: WCAG 2.1.1 Explained

      Keyboard navigation means that every function of a website can be reached and operated with a keyboard alone – usually with Tab, Shift+Tab, Enter, Space and the arrow keys. WCAG 2.1.1 requires it at Level A.

      Read definition: Keyboard Navigation: WCAG 2.1.1 Explained
    • ARIA: Roles, States and Properties Explained

      ARIA (WAI-ARIA, Accessible Rich Internet Applications) is a W3C specification of HTML attributes – roles, states and properties – that tell assistive technology what a custom element is, what it is called and what state it is in.

      Read definition: ARIA: Roles, States and Properties Explained
    • Accessible Carousel: Pause, Controls and Focus

      An accessible carousel is a slider or image rotator that every visitor can control: auto-rotation can be paused or stopped, it stops while the mouse or keyboard focus is on it, previous, next and slide controls have names, and screen readers know which slide is shown. Auto-rotation falls under WCAG 2.2.2 Pause, Stop, Hide at Level A.

      Read definition: Accessible Carousel: Pause, Controls and Focus

    Let AI Handle Website Accessibility

    Built in Europe. Set up in 2 minutes, no developer needed. Put website accessibility on autopilot with AI-powered fixes and automated monitoring.

    1. 1Choose your plan
    2. 2Install in 2 min
    3. 3AI fixes your website
    4. Done