Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. HTML Tag Dictionary
  3. <details> / <summary>

<details> / <summary>

The <details> element creates a disclosure widget that can be opened and closed by clicking. The <summary> element specifies the visible heading label for the toggle control.

Syntax

<details>
  <summary>Click to expand</summary>
  <p>Content shown when open</p>
</details>

Attributes

AttributeDescription
openWhen added to <details>, the content is displayed in the open state when the page loads.

Sample Code

<!-- Accordion that starts closed -->
<details>
  <summary>What is HTML?</summary>
  <p>HTML stands for HyperText Markup Language. It is the language used to describe the structure of web pages.</p>
</details>

<!-- Open by default -->
<details open>
  <summary>What is CSS?</summary>
  <p>CSS stands for Cascading Style Sheets. It is the language used to style the structure created with HTML.</p>
</details>

<!-- You can also include a list inside -->
<details>
  <summary>Common programming languages</summary>
  <ul>
    <li>JavaScript</li>
    <li>Python</li>
    <li>PHP</li>
    <li>Swift</li>
  </ul>
</details>

Output

The first item appears closed (▶ What is HTML?), and the second appears open from the start (▼ What is CSS? + content). Clicking the heading toggles it open or closed.

Notes

Using <details> and <summary> together lets you build an accordion (collapsible) UI without any JavaScript. They are commonly used for FAQs, glossaries, and folding away lengthy supplementary content.

<summary> must always be the first child element of <details>. If you omit <summary>, the browser will display a default label such as "Details," so always provide one explicitly. You can also place heading elements (<h2> through <h6>) or inline elements such as <span> inside <summary>.

The open/closed state can be detected with the JavaScript toggle event, which makes it possible to lazy-load content dynamically when the widget is opened. You can also use the CSS details[open] selector to apply styles only when the element is in the open state.

Browser Compatibility

Chrome Chrome
49+
11 or earlier ×
Firefox Firefox
57+
48 or earlier ×
Safari Safari
18+
5 or earlier ×
Edge Edge
84+
78 or earlier ×
IE IE
11 ×
Not supported in any version
Opera Opera
48+
14 or earlier ×
iOS Safari iOS Safari
18+
5 or earlier ×
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
48 or earlier ×

If you find any errors or copyright issues, please .