Is there a CSS selector (like a pseudo class) that can target the details
element when it is open?
One possible use for this would be to change the color of the summary
element when the user open the details
element.
Use the attribute [open]
selector
details summary {
background: pink;
}
details {
background: lightgreen;
}
details[open] summary {
background: red;
}
<details>
<summary>Details</summary>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Fuga, incidunt dolores! Laudantium fugit aspernatur rem autem, expedita ut id necessitatibus, perferendis, accusantium esse repudiandae?
</details>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With