Overlays & display
Accordion
Accordéon
Demo
Loading demo…
A stack of headings that expand to reveal their content. It shortens a page without hiding anything for good: people open only what they need.
Story
Did you know
The name comes from the instrument: the bellows fold and unfold. For fifteen years every dev rebuilt accordions in jQuery while <details> already did the job on its own.
Timeline
- 2011
<details>ships in Chrome 12. - 2020Edge moves to Chromium: support becomes universal.
- 2023
nameattribute for exclusive accordions (Chrome 120).
Vocabulary
Names
- FR
- Accordéon, volet dépliable, replier / déplier
- EN
- Accordion, disclosure, collapsible, expander
Common uses
- FAQ pages
- Search filters (price, size, brand)
- Long forms split into blocks
- Advanced settings hidden by default
Often paired with
The components it usually sits with, by page type, in reading order.
Blog post
See the mock-upProduct page
See the mock-upPricing page
See the mock-upCode
<details name="faq" open>
<summary>Do you deliver on Sundays?</summary>
<p>No, Monday to Saturday only.</p>
</details>
<details name="faq">
<summary>Can I return an item?</summary>
<p>Yes, within 30 days.</p>
</details>
<!-- Same "name" = only one open at a time. No JS needed. -->Good to know
<details>/<summary>handle toggling, keyboard and state with zero JS.- Giving several
detailsthe samenamemakes an exclusive accordion (one open at a time), native since late 2023. - To animate the height:
interpolate-size: allow-keywordsand the::details-contentpseudo-element, in recent browsers. - Closed content stays findable with Ctrl+F: the browser opens the right
detailsby itself.
Accessibility
Must have
- Use
<details>/<summary>, or a real<button>witharia-expandedandaria-controlsif you build it yourself. - The clickable heading must be reachable by keyboard and open with Enter and Space.
Often forgotten
- Keep a real heading level: put an
<h3>inside the button orsummary, so screen reader users can jump between headings. - Don't remove the marker without adding another one: the icon is what tells people it expands.
Nice to have
- Respect
prefers-reduced-motionif you animate the opening. - Open the section targeted by the URL hash automatically.