SolutionsCase StudiesAI ToolsResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/faq-accordions

7 CSS FAQ Accordions

6 Pure CSS1 with JSPublished 2026-10-05Free · no sign-up

Seven FAQ sections: a classic accordion with plus and minus icons, an exclusive group where only one answer is open, a two-column FAQ, a searchable FAQ, questions grouped by topic, an FAQ with matching structured data and answers that open with a smooth animation.

01. FAQ with Plus and Minus Icons

FAQdetails

Questions in details and summary elements, each with a plus that turns into a minus when open. The disclosure works with mouse, keyboard and screen readers without any script, and the icon is drawn with two pseudo-element bars.

View code
<div class="fq1"><details><summary>How long does delivery take?</summary><p>Two to four working days in the UK, five to eight to the rest of Europe.</p></details><details><summary>Can I return an item?</summary><p>Yes, within 30 days, unused and in its original packaging.</p></details><details><summary>Do you ship outside Europe?</summary><p>Not yet. We hope to add the US next year.</p></details></div>
.fq1 { width: 360px; max-width: 100%; font: 15px Inter, system-ui, sans-serif; }
.fq1 details { border-bottom: 1px solid #e4e7ec; }
.fq1 summary { position: relative; padding: 14px 32px 14px 0; color: #101828; font-weight: 600; cursor: pointer; list-style: none; }
.fq1 summary::-webkit-details-marker { display: none; }
.fq1 summary::before, .fq1 summary::after { content: ""; position: absolute; right: 6px; top: 50%; width: 14px; height: 2px; border-radius: 1px; background: #475467; transition: transform .2s; }
.fq1 summary::after { transform: rotate(90deg); }
.fq1 details[open] summary::after { transform: rotate(0); }
.fq1 p { margin: 0 0 14px; color: #475467; line-height: 1.55; }
.fq1 summary:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .fq1 summary::after { transition: none; } }

02. Only One Answer Open

FAQExclusive

Giving every details element the same name attribute makes them an exclusive group: opening one closes the others, with no JavaScript. Browsers without support simply let several stay open, which is a fine fallback.

View code
<div class="fq2"><details name="fq2" open><summary>Is there a free plan?</summary><p>Yes. Up to three projects, free forever.</p></details><details name="fq2"><summary>Can I cancel any time?</summary><p>Yes. You keep access until the end of the paid period.</p></details><details name="fq2"><summary>Do you offer discounts?</summary><p>Half price for students and non-profits.</p></details></div>
.fq2 { display: grid; gap: 8px; width: 360px; max-width: 100%; font: 15px Inter, system-ui, sans-serif; }
.fq2 details { border: 1px solid #263048; border-radius: 12px; background: #111727; }
.fq2 details[open] { border-color: #6366f1; }
.fq2 summary { padding: 14px 16px; color: #f1f5f9; font-weight: 600; cursor: pointer; }
.fq2 p { margin: 0; padding: 0 16px 14px; color: #94a3b8; line-height: 1.55; }
.fq2 summary:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; border-radius: 10px; }

03. Two-Column FAQ

FAQGrid

On wide containers questions sit in two columns so a long FAQ takes less scrolling; on narrow ones they stack. Each question and answer is a heading and paragraph pair, always visible, which suits short FAQs better than collapsing.

View code
<div class="fq3"><div class="in"><div><h3>Do you work with small shops?</h3><p>Yes, most of our clients have fewer than ten staff.</p></div><div><h3>How long does a project take?</h3><p>Usually four to eight weeks.</p></div><div><h3>Can you migrate my store?</h3><p>Yes, including products, customers and orders.</p></div><div><h3>Do you offer support after launch?</h3><p>Every project includes 30 days of support.</p></div></div></div>
.fq3 { width: 560px; max-width: 100%; container-type: inline-size; font: 14px/1.55 Inter, system-ui, sans-serif; }
.fq3 .in { display: grid; gap: 18px 28px; }
.fq3 h3 { margin: 0 0 4px; color: #101828; font-size: 15px; } .fq3 p { margin: 0; color: #475467; }
@container (min-width: 460px) { .fq3 .in { grid-template-columns: 1fr 1fr; } }

05. FAQ Grouped by Topic

FAQGroups

Long FAQs are easier with topic headings: Orders, Payments, Returns, each with its own questions. The topics are h3 headings so screen reader users can jump between them, and the questions under each are a details group.

View code
<div class="fq5"><h3>Payments</h3><details><summary>Which cards do you accept?</summary><p>Visa, Mastercard and American Express.</p></details><details><summary>Is there a payment plan?</summary><p>Yes, three interest-free instalments.</p></details><h3>Returns</h3><details><summary>Who pays for return postage?</summary><p>We do, using the prepaid label in your parcel.</p></details></div>
.fq5 { width: 360px; max-width: 100%; font: 14px Inter, system-ui, sans-serif; }
.fq5 h3 { margin: 16px 0 4px; color: #6941c6; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; } .fq5 h3:first-child { margin-top: 0; }
.fq5 details { border-bottom: 1px solid #e4e7ec; }
.fq5 summary { padding: 12px 0; color: #101828; font-weight: 600; cursor: pointer; }
.fq5 summary:focus-visible { outline: 3px solid #d6bbfb; outline-offset: 2px; }
.fq5 p { margin: 0 0 12px; color: #475467; }

06. FAQ with Structured Data

FAQSEO

A visible FAQ paired with FAQPage JSON-LD that repeats exactly the same questions and answers. Structured data must match what is on the page, and search engines show FAQ rich results only for some kinds of sites, so treat it as a description, not a guarantee.

View code
<div class="fq6"><details><summary>What is a headless store?</summary><p>A shop whose front end is separate from the commerce platform.</p></details><details><summary>Is headless faster?</summary><p>It can be, when the front end is well built.</p></details><script type="application/ld+json">{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a headless store?","acceptedAnswer":{"@type":"Answer","text":"A shop whose front end is separate from the commerce platform."}},{"@type":"Question","name":"Is headless faster?","acceptedAnswer":{"@type":"Answer","text":"It can be, when the front end is well built."}}]}</script></div>
.fq6 { width: 360px; max-width: 100%; font: 14px Inter, system-ui, sans-serif; }
.fq6 details { margin-bottom: 8px; padding: 0 14px; border-radius: 10px; background: #151b2e; }
.fq6 summary { padding: 12px 0; color: #f1f5f9; font-weight: 600; cursor: pointer; }
.fq6 summary:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.fq6 p { margin: 0 0 12px; color: #94a3b8; }

07. Smoothly Animated Answers

FAQAnimation

Answers open with a smooth height animation in browsers that support interpolate-size and ::details-content, and simply appear elsewhere. No script measures heights, so content can change length freely without breaking the animation.

View code
<div class="fq7"><details><summary>Why choose annual billing?</summary><p>Two months free, and one invoice a year for your accountant.</p></details><details><summary>What happens to my data if I leave?</summary><p>Export everything as CSV or JSON. We delete your account data 30 days after you close it.</p></details></div>
.fq7 { width: 360px; max-width: 100%; font: 15px Inter, system-ui, sans-serif; interpolate-size: allow-keywords; }
.fq7 details { margin-bottom: 8px; border: 1px solid #e4e7ec; border-radius: 12px; background: #fff; }
.fq7 summary { padding: 14px 16px; color: #101828; font-weight: 600; cursor: pointer; }
.fq7 details::details-content { height: 0; overflow: hidden; transition: height .3s ease, content-visibility .3s allow-discrete; }
.fq7 details[open]::details-content { height: auto; }
.fq7 p { margin: 0; padding: 0 16px 14px; color: #475467; line-height: 1.55; }
.fq7 summary:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; border-radius: 10px; }
@media (prefers-reduced-motion: reduce) { .fq7 details::details-content { transition: none; } }

About these CSS FAQ Accordions

details and summary first

The native <details> and <summary> pair gives an accessible disclosure with keyboard support and no script. Style the summary freely and replace the marker with your own icon.

One open at a time

Give every details element in a group the same name attribute and the browser closes the others when one opens. Use it when answers are long; keep multiple open for short ones.

Structured data must match

FAQPage JSON-LD should repeat exactly the questions and answers visible on the page. Search engines show FAQ rich results only for some sites, so use it to describe, not to chase.

Search for long FAQs

Once an FAQ passes about ten questions, a filter box that searches questions and answers saves a lot of scrolling. Report the number of matches in a live region.

Frequently asked questions

Is details accessible?

Yes. It is announced as a disclosure that is expanded or collapsed, and works with Enter and Space.

Will closed answers be indexed?

Content inside closed details is in the HTML, and search engines can read it.

How do I animate details?

Use ::details-content with interpolate-size in supporting browsers, as the last demo does.