Day 16: the specificity of :has()
It’s time to get me up to speed with modern CSS. There’s so much new in CSS that I know too little about. To change that I’ve started #100DaysOfMoreOrLessModernCSS. Why more or less modern CSS? Because some topics will be about cutting-edge features, while other stuff has been around for quite a while already, but I just have little to no experience with it.
Just like with
:not(), the specificity of
:has() is replaced by the specificity of the most specific selector in its selector list argument. Unlike
:has() itself doesn't add to the specificity.
/* A tag and a class */
/* A tag: specificty too low */
/* A class: specificty too low */
/* A tag and a class: same specificty as div:has(.child) */
See on CodePen.