Back to templates

Accessible FAQ accordion

A native <details>/<summary> FAQ accordion requiring zero JavaScript and supporting keyboard navigation.

Source code

1 lines · 1.1 KB
<style>*{box-sizing:border-box}body{margin:0;font-family:Inter,system-ui,sans-serif;background:#f6f7fb;color:#172033}button,a{font:inherit}.wrap{width:min(960px,calc(100% - 32px));margin:auto}</style><style>main{padding:56px 16px}.faq{max-width:680px;margin:auto}details{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:16px 20px;margin:12px 0}summary{font-weight:700;cursor:pointer;list-style:none}details p{margin:12px 0 0;color:#475569;line-height:1.65}</style><main><section class="faq"><h1 style="text-align:center;margin-bottom:28px">Frequently Asked Questions</h1><details open><summary>Do native details elements work without JavaScript?</summary><p>Yes. Browsers handle keyboard toggling, focus, and expanded semantics natively.</p></details><details><summary>Can multiple sections stay open at once?</summary><p>Yes, unless you add a matching name attribute to group them into a mutually exclusive accordion.</p></details><details><summary>How should answers be written?</summary><p>Keep each answer direct and concrete so readers find the rule in one scan.</p></details></section></main>

When this template fits

An accessible FAQ page built purely with native HTML <details> and <summary> elements—zero JavaScript required.

How the layout works

Each question sits inside a semantic summary header that browsers make keyboard-focusable and screen-reader-announced automatically.

What to customize

Group related questions under subheadings if the list grows beyond eight items, and keep answers direct rather than burying rules inside long paragraphs.

Review before publishing

Test opening and closing items with Enter and Space, and confirm contrast and padding remain comfortable when zoomed to 200%.

Keep building with context

Compare a related pattern or read a practical guide before adapting this example in the Playground.