1

I am developing a web page and I need select "parent of" another element but not working and also it not working in a simple page as this:

<!DOCTYPE html>
<html lang="es" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
<div class="">
  <a href="#" class="prueba">prueba!</a>
</div>
<style media="screen">
  div:has(.prueba) {
    border: solid 2px red;
  }
</style>
  </body>
</html>

If I use div in style section, working, but I need catch div with the first child, in this case "a" (class prueba) but not working for me.

Thank you!

Juan Camacho
  • 636
  • 1
  • 6
  • 14

1 Answers1

5

The :has() selector is CSS4 and has almost no browser support yet (Jan 2019). You will need to use Javascript until support exists.

See Can I Use - :has()

SpliFF
  • 35,724
  • 15
  • 80
  • 113