HTML Details and Summary: Disclosure Widgets
Reveal additional information
A disclosure widget reveals or hides related content on demand. Place a meaningful summary first inside details, then the content. The browser provides activation by mouse and keyboard without a script.
<details> <summary>Delivery times</summary> <p>Orders ship in two days.</p></details>Activate the summary to reveal the paragraph; activate again to close it.
Set the initial state
The boolean open attribute starts a disclosure expanded. Its presence matters: open="false" still opens it. Removing the attribute closes it. Do not use details as a replacement for a dialog or tab interface.
<details open> <summary>Study checklist</summary> <ul> <li>Read</li> <li>Practice</li> </ul></details>The checklist is visible initially and can still be collapsed.
Group related disclosures
Give related details elements the same nonempty name to allow at most one to stay open. This feature is newer than details itself. Independent disclosures are a reasonable fallback in older browsers; do not depend on exclusivity for security or correctness.
<details name="faq" open> <summary>Hours</summary> <p>9 to 5</p></details><details name="faq"> <summary>Location</summary> <p>First floor</p></details>Opening Location closes Hours in a browser supporting grouped disclosures.
Common mistakes and practice
Use descriptive summary text, not an unlabeled icon. Do not hide essential instructions by default. Try Tab and Space or Enter; keep the browser focus indicator visible.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Details and Summary: Disclosure Widgets — Knowledge Check
Apply the interaction concepts taught in this lesson.
Which element labels a disclosure?
What does open="false" do?
What makes two details elements exclusive?
Does a native disclosure need a script for toggling?
What is a good summary?