DEV Community

Discussion on: 6 powerful CSS selectors that will really help you write clean CSS.

Collapse
 
alohci profile image
Nicholas Stimpson • Edited

The reasons come down to performance. We can see this from a couple of snippets from the Selectors Level 4 spec, where it discusses the Live and snapshot profiles

Selectors are used in many different contexts, with wildly varying performance characteristics. Some powerful selectors are unfortunately too slow to realistically include in the more performance-sensitive contexts.
ISSUE 1 - The categorization of things into the “live” or snapshot profiles needs implementor review. If some things currently not in the live profile can reasonably be done in CSS Selectors, we should move them.

In this particular case <a> before <div> could be done using the has() pseudo-class as a:has(+ div) or a:has(~ div), but has() is only part of the snapshot profile and therefore not for implementation in CSS.