<summary>...</summary>

HTML4 HTML5

The <summary> tag defines a visible heading or label for a <details> element[cite: 3]. It acts as an interactive button to expand or collapse hidden section content[cite: 3].

It must be placed directly as the first element inside <details>[cite: 3]. If omitted, browsers insert default text (e.g., "Details")[cite: 3].

Both opening and closing tags are mandatory[cite: 3].

Attributes:

Example

In the example below, <summary> creates a visible "Show answer" header that reveals hidden content when clicked[cite: 3]:

Code:

<details> <summary>Show answer to the question</summary> <p>This is hidden content that becomes visible only after clicking the header above.</p> </details>

The browser will interpret this code as follows (heading is interactive)[cite: 3]:

Show answer to the question

This is hidden content that becomes visible only after clicking the header above.