0

I would like to style the div element only if section has :before pseudo.

<section>
  <div>something</div>
</section>

Something like this:

section:has(:before) {
 div {
   background-color: grey;
 }
}
Finn
  • 1
  • 1
  • it can be done with only JS: https://stackoverflow.com/q/58001666/8620333 – Temani Afif Nov 24 '20 at 10:01
  • This is a workaround: you can change whatever css attribute you want to a :before pseudoclass, since those who don't have a :before with the attribute content set wont be affected. So section:before {background:red;} will affect only those with :before and the attribute content:""; even if it's empty. – Sabina Hernández Gracia Nov 24 '20 at 11:32

0 Answers0