::details-content CSS pseudo-element

Baseline 2025
Newly available

Since September 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The ::details-content CSS pseudo-element represents the expandable/collapsible contents of a <details> element.

Try it

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>

Syntax

css
selector::details-content

Examples

Basic example

This example demonstrates basic usage of the ::details-content pseudo-element to style the content of a <details> element.

HTML

Our <details> element includes a <summary> element, whose contents will always be visible. The details content includes a <p> element.

html
<details>
  <summary>Click me</summary>
  <p>Here is some content</p>
</details>

CSS

We set a background-color on the ::details-content pseudo-element:

css
details::details-content {
  background-color: #a29bfe;
}

Result

Click on the summary to view the detail contents.

Transition example

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.

HTML

The HTML is the same as in the previous example.

html
<details>
  <summary>Click me</summary>
  <p>Here is some content</p>
</details>

CSS

To achieve our transition, we specify two separate transitions inside the transition shorthand property:

  • The opacity property is given a basic transition over 600ms to create the fade-in/fade-out effect.
  • The content-visibility property (which is toggled between hidden and visible when the <details> content is expanded/collapsed) is given a 600ms transition 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.
css
details::details-content {
  opacity: 0;
  transition:
    opacity 600ms,
    content-visibility 600ms allow-discrete;
}

details[open]::details-content {
  opacity: 1;
}

Result

To see the animation, toggle the visibility of the detail contents by clicking on the summary.

Specifications

Specification
CSS Pseudo-Elements Module Level 4
# details-content-pseudo

Browser compatibility

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
Chrome – Full support
Chrome 131 (Release date: 2024-11-12)
footnote Full support
Edge – Full support
Edge 131 (Release date: 2024-11-14)
footnote Full support
Firefox – Full support
Firefox 143 (Release date: 2025-09-16)
footnote Full support
Opera – Full support
Opera 116 (Release date: 2025-01-08)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote
footnote Does not support chaining pseudo-elements after ::details-content. See bug 283446.
Chrome Android – Full support
Chrome Android 131 (Release date: 2024-11-12)
footnote Full support
Firefox for Android – Full support
Firefox for Android 143 (Release date: 2025-09-16)
footnote Full support
Opera Android – Full support
Opera Android 87 (Release date: 2025-01-22)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote
footnote Does not support chaining pseudo-elements after ::details-content. See bug 283446.
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 131 (Release date: 2024-11-12)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18.4 (Release date: 2025-03-31)
footnote
footnote Does not support chaining pseudo-elements after ::details-content. See bug 283446.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also