FRENVersion française

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

  1. 2011<details> ships in Chrome 12.
  2. 2020Edge moves to Chromium: support becomes universal.
  3. 2023name attribute 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.

Code

<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 details the same name makes an exclusive accordion (one open at a time), native since late 2023.
  • To animate the height: interpolate-size: allow-keywords and the ::details-content pseudo-element, in recent browsers.
  • Closed content stays findable with Ctrl+F: the browser opens the right details by itself.

Accessibility

Must have

  • Use <details>/<summary>, or a real <button> with aria-expanded and aria-controls if 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 or summary, 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-motion if you animate the opening.
  • Open the section targeted by the URL hash automatically.

Who uses it