<summary>

Term side of the Card.
Topic: Interactive
Unit title: <summary>
Categories: Tag
Explanation side of the Card

Explanation: The element that provides a summary or caption for the content of a `<details>` element. It acts as a clickable header, which, when clicked, toggles the visibility of the content within the `<details>`.

Browser compatibility:
  • The chrome browser supports this feature starting from version 12.
  • The edge browser supports this feature starting from version 79.
  • The firefox browser supports this feature starting from version 49.
  • The safari browser supports this feature starting from version 6.
Availability: 

Example

Wrongcss
summary {
  list-style: none;
}
Rightcss
summary {
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}

Safari draws the marker with a WebKit pseudo-element, so both rules are needed to hide the arrow everywhere.

Common mistakes

  • Putting a <button> inside <summary>, which creates nested interactive controls.
  • Hiding the marker with list-style: none only, leaving it visible in Safari.

Key points

  • <summary> is the first child of a <details> element.
  • <summary> contains no buttons, links or other interactive elements.
  • Hiding the arrow also covers WebKit with summary::-webkit-details-marker.

Interview questions

Can I put a heading inside summary?

Yes, it is valid, but <summary> acts as a button, so some screen readers do not announce the heading level.

What happens if details has no summary?

The browser shows a default label such as 'Details'. Always add your own <summary> with clear text.

How do I style the summary arrow?

Use summary::marker to change its color or content, or hide it and add your own icon with ::before.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy