Why has not working in CSS [select parent] [duplicate]

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> <a href="#">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!

3

1 Answer

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()

You Might Also Like