Accessibility
a11y/accordion-header
Each accordion header is a button with aria-expanded inside a heading of the right level; or use details and summary.
moderatemanualWCAG 1.3.1, 4.1.2 · Afe-a11y-tabs-accordion
Why
Clickable div headers cannot be reached with the keyboard, and without a heading around them screen reader users cannot jump between sections; without aria-expanded they cannot tell which section is open.
Fix
Simplest: <details name="faq"><summary>Question</summary>…</details> (a shared name keeps one open at a time). Custom: <h3><button type="button" aria-expanded="false" aria-controls="panel-1">Question</button></h3> and a panel with id="panel-1" that is hidden when closed. Add role="region" with aria-labelledby to panels only when there are few of them.
Examples
<!-- bad -->
<div class="accordion-header" onclick="toggle(1)">Shipping</div>
<!-- good -->
<h3><button type="button" aria-expanded="false" aria-controls="ship">Shipping</button></h3>
<div id="ship" hidden>…</div>Sources
Facts
- Id
a11y/accordion-header- Severity
- moderate
- Check
- manual a person reviews it; the report lists it as a checklist
- Applies to
htmlangularvuesvelteastrojsx- WCAG 2.2
- 1.3.1, 4.1.2, level A
- Taught by the skill
fe-a11y-tabs-accordionTabs and accordions- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain a11y/accordion-header