HTML Reference ยท Interactive Elements
The <summary> element
Reference for the HTML <summary> element: the clickable label of a <details> widget, what it may contain, marker styling, accessibility and technical details.
The <summary> element is the label of a <details> widget. It stays visible while the rest of the widget is collapsed, and activating it, by click, tap, Enter or Space, toggles the parent open or closed. It only does this when it is the first child of a <details> element.
<details> <summary>Ingredients</summary> <ul> <li>2 cups flour</li> <li>1 egg</li> </ul> </details>
Try it
Attributes
This element has no attributes of its own. It accepts the global attributes, such as class, id and lang.
Usage notes
- Keep it short and descriptive. The summary is read aloud as the control's name, so "Delivery options" is better than "Click here for more".
- No interactive content inside. Links, buttons or form fields inside a
<summary>fight with its own click behavior and confuse assistive technology. Put them in the body of the<details>instead. - Headings are allowed. A summary may contain a heading along with phrasing content, which is handy for FAQ pages. Be aware that because the summary is exposed as a button, some screen readers announce it as a button and not as a heading.
- Markers. Browsers render the summary as
display: list-item, which produces the disclosure triangle. Style it withsummary::marker, or remove it withlist-style: none(plussummary::-webkit-details-markerfor older Safari). If you changedisplaytoblockorflex, the marker disappears. - Don't toggle it yourself. Clicking the summary changes the parent's
openattribute. Listen for thetoggleevent on the<details>element instead ofclickon the summary. - Accessibility. Browsers expose the summary as an expandable control and announce whether it is expanded or collapsed. Don't add
role="button"oraria-expandedyourself; the native semantics already cover it.
Technical summary
| Content categories | None |
| Permitted content | Phrasing content, optionally intermixed with heading content (<h1>โ<h6>, <hgroup>) |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | A <details> element, as its first child |
| Implicit ARIA role | No corresponding role (browsers expose it as an expandable button-like control) |
| DOM interface | HTMLElement |
| Default display | list-item |
Browser support
Supported in every current browser. Styling the marker with ::marker works everywhere today, while older Safari versions only respond to ::-webkit-details-marker.
Related
<details>โ the disclosure widget a summary labels<h1>โ<h6>โ headings, which may appear inside a summary<button>โ a general-purpose control for everything else- Lesson: Collapsible Sections with Details