For a simple accordion that opens and closes without JavaScript, use HTML’s native <details> and <summary> elements, then style them with CSS. The browser manages each panel’s state; you can choose whether several panels may stay open or whether opening one closes the others.
Build a basic CSS-only accordion
Place each disclosure in a <details> element and make its first child a concise <summary> label. Content after the summary is the panel. This example lets visitors open multiple answers at once:
As an Amazon Associate I earn from qualifying purchases.
<div class="accordion">
<details>
<summary>What is a pure CSS accordion?</summary>
<p>A group of collapsible content panels styled with CSS.</p>
</details>
<details>
<summary>Does it require JavaScript?</summary>
<p>This native disclosure version does not require JavaScript for toggling.</p>
</details>
</div>
.accordion details {
border-block: 1px solid #c8c8c8;
}
.accordion summary {
cursor: pointer;
padding: 1rem;
font-weight: 600;
}
.accordion details[open] > summary {
border-bottom: 1px solid #c8c8c8;
}
.accordion details > :not(summary) {
margin: 0;
padding: 1rem;
}
The open attribute reflects whether a <details> panel is expanded. The CSS selector details[open] lets you change its appearance without managing a separate state variable. See MDN’s details element reference for the element’s behavior and browser availability.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Choose whether panels open independently or exclusively
Allow multiple panels to remain open
Leave the name attribute off each <details> element, as in the first example. Visitors can expand several items and keep their contents visible while reading.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Keep only one panel open at a time
Give every disclosure in the group the same name value:
<details name="faq">
<summary>First question</summary>
<p>First answer.</p>
</details>
<details name="faq">
<summary>Second question</summary>
<p>Second answer.</p>
</details>
In an exclusive group, opening one disclosure closes another in the same group. This behavior is defined by the HTML Standard’s interactive elements specification.
Rank #2
Make the accordion usable
- Keep
<summary>as the first child of each<details>, and use text that clearly identifies the content it reveals. - Make the summary area comfortably large to activate, and preserve a visible keyboard-focus indicator. Avoid removing the browser’s focus outline unless you replace it with a clear alternative.
- Check the finished design in the browsers and with the assistive technologies your audience uses. Native disclosure elements provide a useful baseline, but styling and behavior should be checked in the actual interface.
When native disclosure is not the right fit
A checkbox-and-label technique can expose a CSS state, but it requires careful label association, focus handling, keyboard behavior, and assistive-technology testing. For ordinary show-and-hide content, native disclosure is the more direct option.
Free tools Windows power users keep installed
One-click scans. No signup required.
If the design requires a richer button-and-panel widget, the W3C’s accordion pattern describes a different approach using buttons, aria-expanded, and aria-controls. Its example includes JavaScript and CSS; it is not the same no-script native disclosure pattern shown here.
Quick Recap
Best Value
Rank #4
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




