This feature is not Baseline because it does not work in some of the most widely-used browsers.
The ::details-content CSS pseudo-element represents the expandable/collapsible contents of a <details> element.
details[open]::details-content {
color: dodgerblue;
padding: 0.5em;
border: thin solid grey;
}
<details open>
<summary>Example summary</summary>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
<p>
Architecto cupiditate ea optio modi quas sequi, esse libero asperiores
debitis eveniet commodi hic ad.
</p>
</details>
selector::details-content
In this example the ::details-content pseudo-element is used to set a background-color on the content of the <details> element.
<details> <summary>Click me</summary> <p>Here is some content</p> </details>
details::details-content {
background-color: #a29bfe;
}
In this example the ::details-content pseudo-element is used to set a transition on the content of the <details> element so that it smoothly fades into view when expanded, and fades out again when collapsed. To achieve this, two separate transitions are specified inside the transition shorthand property:
opacity property is given a basic transition over 600ms to create the fade-in/fade-out effect.content-visibility property (which is toggled between hidden and visible when the <details> content is expanded/collapsed) is also given a basic 600ms transition, but with the transition-behavior value allow-discrete specified. This opts the browser into having a transition started on content-visibility, the animation behavior of which is discrete. The effect is that the content is visible for the entire duration of the transition, allowing other transitions to be seen. If this transition was not included, the content would immediately disappear when the <details> content was collapsed — you wouldn't see the smooth fade-out.<details> <summary>Click me</summary> <p>Here is some content</p> </details>
details::details-content {
opacity: 0;
transition:
opacity 600ms,
content-visibility 600ms allow-discrete;
}
details[open]::details-content {
opacity: 1;
}
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
::details-content |
131 | 131 | 143 | 116 | 18.4Does not support chaining pseudo-elements after::details-content. |
131 | 143 | 87 | 18.4Does not support chaining pseudo-elements after::details-content. |
No | 131 | 18.4Does not support chaining pseudo-elements after::details-content. |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/::details-content