Skip to content
easeweb
Search topics

Accordions that don't say whether a panel is open

A clickable heading expands a panel, but its role and expanded state are missing.

WCAG 2.2
SC 4.1.2ASC 2.1.1A
Required by
Section 508 · EN 301 549 (EU)
Broken <h3 onclick="toggle(this)">
The accessibility problem illustrated: Motor:How do I reach it?
01

The problem

Keyboard and screen reader users can't tell which headings open, or whether they are open

02

Try it

Open the answer with Tab and Enter

Does Tab stop on the question, and do Enter and Space open it? Then click it: does the screen reader say it is a button, and whether it is open?

Broken Can you fix this?

BrokenA clickable heading and a squeezed panel

How do refunds work?

Refunds arrive within 5 days. Refund policy

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Make each toggle say whether its panel is open

Before
BrokenA clickable heading and a squeezed panel
<h3 class="faq-q" onclick="toggle(this)">How do refunds work?</h3><div class="faq-a" style="height: 0; overflow: hidden">  <p>Refunds arrive within 5 days. <a href="/refunds">Refund policy</a></p></div>
What is wrong3 points
  • A keyboard user can't open the answer. The question is an h3 with a click handler, so Tab passes over it and no key opens it.
  • A screen reader user isn't told that the question opens, or whether it is open. It is exposed as a heading, with nothing to give its state.
  • Focus disappears into the closed answer. The panel is only squeezed to zero height, so its link still takes a Tab stop where nobody can see it.
After

A native disclosure

<details>  <summary>How do refunds work?</summary>  <p>Refunds arrive within 5 days. <a href="/refunds">Refund policy</a></p></details>
How it is fixed2 steps
  1. Replace the heading and its panel with details, and make the question its summary. Tab reaches it, and Enter, Space or a click opens it, with no script.
  2. Put the answer inside the details, after the summary. The browser reports it open or closed, and while it is closed its link is out of the tab order.

This fixes the Before and passes 2.1.1 and 4.1.2, for a simple question and answer. Two of the extras a custom accordion is kept for work on details too: ::details-content selects the panel to style or animate, and giving several details the same name keeps only one open at a time (both in Chrome, Edge, Firefox and Safari in October 2026).

Why this fix: Use native HTML first

04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Forced colors

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared accordion component changes.

How screen readers handle aria-expanded

Limits

This is a starting pattern, not a guarantee for every application. The script is a minimal sketch without animation or deep links. A click target elsewhere on the page that isn't a heading's toggle, such as a div that saves or opens something, is covered in div buttons that can't be reached with Tab. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service