Accessible Accordions and Tabs: WAI-ARIA 1.2 Design Patterns & Keyboard Interaction
Master WAI-ARIA 1.2 design patterns for accordions and tab panels. Learn proper keyboard arrow key handling, ARIA bindings, and focus state management.
Accordions and tabbed interfaces are among the most common disclosure components used in modern web design for FAQs, pricing comparisons, and configuration dashboards. However, using unstyled <div> tags with custom click handlers creates major accessibility hurdles for screen reader and keyboard-only users. Adhering to the **WAI-ARIA 1.2 Authoring Practices** guarantees full compliance and intuitive navigation.
In an accordion, users navigate between header buttons using the standard Tab key. In a tabbed interface (role="tablist"), users move between tabs using ← and → arrow keys, while Tab moves focus directly into the active tab's content panel.
When to Use Accordions vs Tab Panels
Choose accordions when multiple sections may need to be expanded simultaneously or when designing for narrow mobile viewports. Choose tabs when content sections represent mutually exclusive views on wider screens.
The WAI-ARIA Accordion Pattern (aria-expanded, aria-controls)
An accessible accordion structure requires:
- Each accordion header must be wrapped in an appropriate heading tag (
<h2>,<h3>). - The header trigger must be a native
<button>element. - The button must carry
aria-expanded="true|false"andaria-controls="panel-id".
The WAI-ARIA Tabs Pattern (tablist, tab, tabpanel)
| Element Role | Required ARIA Attributes | Keyboard Behavior |
|---|---|---|
role="tablist" |
aria-label="Section name" |
Container holding the tab buttons. |
role="tab" |
aria-selected="true|false", aria-controls="panel-id", tabindex="0|-1" |
Arrow keys navigate between tabs; roving tabIndex active. |
role="tabpanel" |
aria-labelledby="tab-id", tabindex="0" |
Receives focus when tabbing out of tablist. |
Keyboard Interaction Models (Arrow Keys vs Tab)
For tabs, implement roving tabindex: only the currently selected tab has tabindex="0", while all unselected tabs have tabindex="-1". Pressing → or ← updates selection and shifts focus.
Production-Ready Code Implementation
<!-- Accessible Accordion Item -->
<div class="accordion-item">
<h3 class="accordion-header">
<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls="faq-ans-1" id="faq-btn-1">
How does continuous accessibility scanning work?
</button>
</h3>
<div id="faq-ans-1" class="accordion-panel" role="region" aria-labelledby="faq-btn-1" hidden>
<p>Rogabot continuously scans your web pages on autopilot...</p>
</div>
</div>
Audit Your Website for WCAG 2.2 Compliance Today
Scan your domain in 60 seconds with Rogabot and get instant PR-ready code diffs to prevent ADA lawsuit exposure.