Skip to content

HTML Tutorial Semantic HTML

details and summary: Expandable Content Without JavaScript

Lesson 61 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

details makes content that the visitor can expand and collapse, with no JavaScript. summary is the part that is always visible.

index.html
HTML
<details>
  <summary>What are your opening hours?</summary>
  <p>Every day from nine to six, except public holidays.</p>
</details>

<details open>
  <summary>Do you buy used books?</summary>
  <p>Yes. Bring them to the counter and we will take a look.</p>
</details>

How it works

  • Clicking or pressing Enter on the summary toggles the content.
  • The open attribute makes it start open.
  • It works with the keyboard, and screen readers announce expanded or collapsed.

Good uses

  • FAQ lists.
  • Optional extra information, such as technical details.
  • The solution to an exercise, like the ones in this course.

Several that behave like an accordion

Give details elements the same name to allow only one to be open at a time in modern browsers.

index.html
HTML
<details name="faq"><summary>First</summary><p>...</p></details>
<details name="faq"><summary>Second</summary><p>...</p></details>
warning
Hiding important content
Do not hide essential information, such as delivery costs, inside a collapsed details. People may not open it, and search tools may give it less weight.