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.
<h3 onclick="toggle(this)"> The problem
Keyboard and screen reader users can't tell which headings open, or whether they are open
An FAQ lists its questions as headings. Click "How do refunds work?" and the answer opens below it, and the plus turns to a minus. But the question is only a heading: Tab passes over it, and Enter and Space do nothing, so a keyboard user can't open the answer at all. A screen reader reads it as "How do refunds work?, heading level 3", with nothing to say that it opens, or whether it is open now. While the answer is closed, its Refund policy link still takes a Tab stop, so focus disappears into a panel nobody can see.
Success criterion 2.1.1 Keyboard asks that everything the mouse can do, the keyboard can do. The question is a heading with a click handler. A heading takes no focus, and the browser turns Enter and Space into a click only on a control such as a button, so no key opens the answer.
Success criterion 4.1.2 Name, Role, Value asks that a control exposes its role and its current state. The question is exposed as a heading, so a screen reader user isn't told it can be pressed, and nothing such as aria-expanded says whether its answer is open. The plus and minus are drawn for the eye only.
The closed answer is also only squeezed to zero height, not hidden, so its link stays in the tab order where nobody can see it.
Anyone scanning the page can't tell which headings open a panel and which are only headings.
3 of 10 groups affected
- No vision (affected)
- Low vision (affected)
- Colour vision (not affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (affected)
- Reach, strength (not affected)
- Cognitive (not affected)
- Seizures (not affected)
- Limited manipulation Keyboard users can't open a panel at all, and meet invisible tab stops on the links inside closed panels, which loses their place.
- Without vision Screen reader users can't reliably discover which headings are interactive or whether a panel is open.
- Limited vision People with low vision who find the pointer hard to track can't open a panel from the keyboard instead.
Automation can detect some missing attributes, but it cannot establish that aria-expanded matches every state transition or that hidden descendants stop receiving focus. Test repeated opening and closing.
What the checkers report
- axe DevTools
- ARIA attributes must conform to valid values
- Buttons must have discernible text
- Lighthouse
[aria-*]attributes do not have valid values- Buttons do not have an accessible name
- WAVE
- Empty button
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?
How do refunds work?
Refunds arrive within 5 days. Refund policy
The fix
Make each toggle say whether its panel is open
<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
h3with 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.
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
- Replace the heading and its panel with
details, and make the question itssummary. Tab reaches it, and Enter, Space or a click opens it, with no script. - Put the answer inside the
details, after thesummary. 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
Both options pass. Start with details and summary for a simple question and answer: there is no script to keep in step and no ARIA to get wrong. Choose the custom accordion only when you need something the native element can't do well, such as an animated panel, one control that opens or closes several panels, or a design the summary can't be styled to match.
Avoid making the entire heading and a separate icon two different toggle controls. A native disclosure usually needs no extra aria-expanded. For custom controls, use stable IDs with aria-controls, and decide whether several panels may stay open. Arrow-key shortcuts are optional; Tab access must remain usable.
Keep the heading level that fits the page outline, so the questions still work as headings for screen-reader navigation.
Verify the fix
5 checks, no mouse.
Test with: Keyboard, Screen reader, Zoom, Forced colors
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.