3 ms·
Possibly stupid question, is there a reason they went with parent:has(child) Instead of parent < child Which seems a bit more intuitive to me given
by Wowfunhappy 4y ago
Possibly stupid question, is there a reason they went with
parent:has(child)
Instead of
parent < child
Which seems a bit more intuitive to me given that the inverse is a thing.
- henrikeh 4y agoThe article gives a few examples where a pseudo-class fits better with how CSS normally works. For example, the selector matches the last item in the selector. With ‘<‘ it would match ‘parent’ in your case. You can also match descendants of something with the :has() selector. It really is more than a “parent selector”
- silvestrov 4y agoExample of this: div:has(b) a which matches a link inside a div that also contains bold text. The important part is that 'b' and 'a' can be very different places in the hierachy, they don't need to be same like like a 'b + a' selector.