The CSS :has Selector (and 4+ Examples) | CSS-Tricks - CSS-Tricks

PHOTO EMBED

Thu Nov 24 2022 10:33:23 GMT+0000 (Coordinated Universal Time)

Saved by @danlourenco #css

div:has(p) {
  background: red;
}
/*
  <div> <!-- selected! -->
     <p></p>
  <div>

  <div></div> <!-- not selected -->
  <div> <!-- not selected -->
    <section></section>
  </div>
*/
content_copyCOPY

https://css-tricks.com/the-css-has-selector/