What is the CSS Accordion Generator?
Build animated CSS accordions using the details/summary HTML elements. No JavaScript required for open/close functionality.
Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.
Using the CSS Accordion Generator
Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.
Set spacing and borders
Adjust the summary padding and border style. Common accordions use 14-16px vertical padding in the summary.
Choose animation style
The CSS-only version uses the browser default details open/close (instant). Smooth height animation requires JavaScript or the experimental interpolate-size: allow-keywords property.
Copy the CSS and HTML
Click Copy to get the CSS. The generator also shows the minimal HTML with details, summary, and content div.
What the generated code looks like
Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.
details.accordion {
border: 1px solid #e5e7eb;
border-radius: 8px;
overflow: hidden;
margin-bottom: 8px;
}
details.accordion summary {
padding: 14px 20px;
cursor: pointer;
font-weight: 600;
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
user-select: none;
}
details.accordion summary::after {
content: '+';
font-size: 1.25rem;
transition: transform 0.2s;
}
details.accordion[open] summary::after {
transform: rotate(45deg);
}
details.accordion .accordion-body {
padding: 0 20px 14px;
}The HTML details and summary elements provide open/close behaviour natively. No JavaScript is required. The open attribute is added by the browser when the details element is expanded.
Pro tips for better results
CSS-only height animation is now possible in Chrome 129+
Chrome 129 added interpolate-size: allow-keywords to the :root. This enables transition: height 0.3s allow-discrete on the details element without JavaScript.
Frequently asked questions
From the blog
Read more →Modern CSS techniques every developer should know
A practical tour of the CSS features that replaced yesterday’s hacks.
From design to code without the friction
How visual generators speed up the build without sacrificing clean output.
Writing CSS that scales with your project
Tokens, naming, and structure that keep large stylesheets maintainable.