Web & Browser APIs
The browser has a built-in disclosure widget that replaces your hand-rolled accordion — toggle state, keyboard navigation, accessibility semantics, and a CSS hook, all with zero JavaScript.
The <details> element and its <summary> child form a native HTML disclosure widget. The browser handles the toggle, exposes an open boolean attribute you can read, set, and style against, fires a toggle event, and provides correct keyboard and screen-reader semantics — all without a single line of JavaScript or any external library.
Container element. Everything inside except <summary> is hidden content.
The always-visible clickable label that toggles the panel open or closed.
Boolean attribute on <details> — present when expanded, absent when collapsed.
Target details[open] to style the expanded state without JS class toggling.
Wrap your hidden content in <details> and put a <summary> as the first child — that is the label users click.
Click or press Enter/Space on the summary — the browser adds or removes the open attribute automatically.
Use details[open] to rotate a caret, change colors, or animate. The disclosure marker is styleable with ::marker or list-style.
The toggle event fires after state change — listen only when you actually need side-effects like analytics.
Stack multiple <details> elements — each is independent, no "accordion group" logic needed.
Group advanced options in a collapsible section that starts closed, keeping the default view clean.
Hide verbose release notes or API details behind a summary so the page stays scannable.
Wrap solutions or answers — users opt in to reveal, no framework dependency.
interpolate-size is in progress but not universally available.