HTML <details> Tag

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

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.

HTML Syntax

syntax.html
<details><summary> label</summary> …content… </details>

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).

Attributes

Attributes specific to <details> (plus globals):

AttributeDescriptionTry it
openBoolean — when present, the details body is visibleTry it
nameGroup name — same value links panels so only one can be openTry it

Global Attributes

The <details> tag also supports the Global Attributes in HTML.

Live Preview

Toggle start state or open the widget below. No JavaScript is required for the disclosure itself.

A real <details> with <summary>. Click the summary to toggle.

Disclosure
System requirements

Needs an OS, some memory, storage, and an input/output device.

Starts closed — open attribute absent

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Disclosure

Pair <details> with a <summary> label.

HTML
<details>
  <summary>System requirements</summary>
  <p>
    Needs an OS, some memory, storage, and an input/output device.
  </p>
</details>
Try It Yourself

How It Works

  1. Open <details> as the disclosure container.
  2. Add <summary> with a short, clear label.
  3. Put the body (paragraphs, lists, etc.) after the summary.
  4. Click or press Space on the summary to open and close.

Example 2 — Start Open

Add the Boolean open attribute so content is visible on load.

HTML
<details open>
  <summary>Shipping note</summary>
  <p>Orders ship within 2 business days.</p>
</details>
Try It Yourself

How It Works

  1. Write <details open> (no value needed).
  2. Keep a clear <summary> so users know what they can collapse.
  3. To close by default later, delete the open attribute.
  4. Avoid open="false" — that still opens the panel.

Example 3 — Exclusive Group with name

Same name on several widgets keeps only one open at a time.

HTML
<details name="reqs">
  <summary>Graduation requirements</summary>
  <p>40 credits including health and history.</p>
</details>
<details name="reqs">
  <summary>System requirements</summary>
  <p>An OS, memory, and storage.</p>
</details>
<details name="reqs">
  <summary>Job requirements</summary>
  <p>HTML, CSS, JavaScript, and accessibility.</p>
</details>
Try It Yourself

How It Works

  1. Pick a shared group name (e.g. reqs).
  2. Set name="reqs" on each related <details>.
  3. Open one panel — others in the group close automatically.
  4. 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>
Try It Yourself

How It Works

  1. Write the question inside each <summary>.
  2. Put the answer in the following content.
  3. Repeat for each FAQ item.
  4. 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.

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 Chrome 12+
Full support
Mozilla Firefox 49+
Full support
Apple Safari 6+
Full support
Microsoft Edge 79+
Full support
Opera 15+
Full support
Samsung Internet All
Full support
Internet Explorer No
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.

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.

Default CSS Settings

Browsers typically show a disclosure triangle next to the summary. A simplified idea:

default.css
details {
  display: block;
}

summary {
  display: list-item;
  cursor: pointer;
}

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.

Next: dfn

Mark the defining instance of a term with the dfn element.

dfn tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful