The <details> element creates a disclosure widget: a control that shows or hides extra content. Put the always-visible label in <summary>; put the hidden body after it.
Users open it with a click or by focusing and pressing Space. Use open to start expanded, and name to group panels so only one stays open (accordion-style).
Baseline · Widely available.
Core <details> / <summary> has been widely available since about January 2020. Some extras (such as exclusive name grouping) have newer or uneven support — test if you rely on them.
Boolean trap: open="false".
Presence of open means open. To hide content, remove the attribute entirely — do not set it to false.
Both start and end tags are required. Permitted content is one <summary> followed by flow content. The widget has two states: closed (label only) and open (label + body).
Open one panel — others in the same name group should close (where supported).
How It Works
Pick a shared group name (e.g. reqs).
Set name="reqs" on each related <details>.
Open one panel — others in the group close automatically.
Panels need not be adjacent in the HTML source to share a name.
Example 4 — Simple FAQ
A common pattern: one question per summary, answer in the body.
HTML
<details>
<summary>Do I need JavaScript?</summary>
<p>No for basic open and close — the browser handles it.</p>
</details>
<details>
<summary>Can several stay open?</summary>
<p>Yes by default. Use the same name to allow only one open.</p>
</details>
No for basic open and close — the browser handles it.
Can several stay open?
Yes by default. Use the same name to allow only one open.
How It Works
Write the question inside each <summary>.
Put the answer in the following content.
Repeat for each FAQ item.
Optional: share a name if you want accordion behavior.
Edge Cases & Pitfalls
Most bugs come from missing summary, Boolean open mistakes, or assuming identical name support everywhere.
structure
Always include summary
The summary is the accessible name of the control. Write a clear label users can understand closed or open.
boolean
open="false" still opens
Boolean attributes are true when present. Remove open to start closed.
support
name grouping is newer
Exclusive accordion via name needs a modern browser. Progressive-enhance or test your target browsers.
vs dialog
Not a modal
Use <dialog> for overlays that trap focus. <details> stays in the page flow.
seo / content
Content is still in the HTML
Closed details are hidden visually but remain in the document. Do not put secrets there hoping they are private.
Compatibility
Browser Support
The <details> element is standard HTML. Core disclosure support is widely available; some related features vary.
✓ Baseline · Widely available*
<details>
Widely available since about January 2020 for details/summary. The exclusive name attribute and some styling hooks (e.g. ::details-content) are newer — check compatibility for those.
95%Global support (approx.)
Google Chrome12+
Full support
Mozilla Firefox49+
Full support
Apple Safari6+
Full support
Microsoft Edge79+
Full support
Opera15+
Full support
Samsung InternetAll
Full support
Internet ExplorerNo
Not supported
<details>Widely supported
Bottom line: Safe for modern sites without JS for basic toggles. Treat name-based exclusive accordions as progressive enhancement until your audience supports them.
Remember
Key Takeaways
Role: native show/hide without JavaScript for the toggle itself.
Label: always provide a clear <summary>.
State:open starts expanded; remove it to start closed.
Groups: shared name can make exclusive accordion panels.
One line:<details> + <summary> is a built-in disclosure — click to reveal, no JS required for the basics.
UA style
Default CSS Settings
Browsers typically show a disclosure triangle next to the summary. A simplified idea:
Style the marker with list properties / ::marker, and the open state with details[open] or :open where supported. Prefer light custom CSS for study pages.
Frequently Asked Questions
The details element creates a disclosure widget. Content stays hidden until the user opens it. Provide a label with a nested summary element.
Yes for a proper widget. summary supplies the visible label. Without it, browsers may show a default label, but you should always include a clear summary.
Add the Boolean open attribute: <details open>. To close it, remove the attribute entirely — open="false" still means open because Boolean attributes are true when present.
Give several details elements the same name attribute. Opening one closes the others in that group (support is modern; test critical UIs).
No for basic open/close. The browser handles the toggle. You can listen for the toggle event if you need scripting.
No. details is an inline disclosure. dialog is a modal or non-modal dialog overlay for focused interactions.