Skip to the page
html reference · grouping

HTML <details> / <summary> tags

closing tag
required (both)
void element
no
lives inside
anywhere in <body>
typically holds
a <summary> first, then the content it reveals

Where it goes

Anywhere content should stay hidden until asked for. <summary> must be the first thing inside <details>. Everything after it is the hidden part.

Example

<details>
  <summary>Does this work offline?</summary>
  <p>Yes — everything runs in the browser.</p>
</details>

Open this example in the editor →

Common mistakes

  • Rebuilding this with <div>s and a click handler. A hand-made version has to recreate the keyboard support and open or closed state that <details> already gives you.
  • Putting <summary> anywhere but first. If it is not first, the browser invents a default "Details" label and your summary ends up hidden.
  • Hiding the thing most visitors came for. If it should start open, add the open attribute: <details open>.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.