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:
class, id, and style are used[cite: 3].In the example below, <summary> creates a visible "Show answer" header that reveals hidden content when clicked[cite: 3]:
Code:
The browser will interpret this code as follows (heading is interactive)[cite: 3]:
This is hidden content that becomes visible only after clicking the header above.