# Accessible Tabs: ARIA Roles and Arrow Keys

Source: https://allyway.ai/glossary/accessible-tabs

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 `div`s 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](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html) (Level A): for scripted components, the [name, role and value](https://allyway.ai/glossary/name-role-value) must be programmatically determinable, and changes to states must be available to assistive technologies. The W3C [Tabs Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) 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](https://allyway.ai/glossary/tabindex).

> **Tip:** > **Automatic or manual activation?**
> W3C recommends showing a panel as soon as its tab gets focus only if the panel appears without noticeable delay. If panels load content from the server, let users confirm with Enter or Space.

## Examples

```html title="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](https://allyway.ai/glossary/keyboard-navigation) baseline even before the script runs.

**Do:** 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:** 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

Q: How do you make tabs accessible?
A: 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.

Q: Should arrow keys or the Tab key switch tabs?
A: 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.

Q: Do tabs need aria-controls?
A: 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.

Q: Are tabs bad for accessibility?
A: 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.

Q: Which WCAG criterion applies to tabs?
A: Mainly 4.1.2 Name, Role, Value, plus 2.1.1 Keyboard and 2.4.7 Focus Visible – all part of [WCAG 2.2](https://allyway.ai/regulations/wcag-2-2).
