:has() pseudo-class is available under "Experimental Web Platform features" (see chrome://flags) in @ChromiumDev since version 101.0.4937. You can start playing with the parent selector in Chrome Canary thanks to the awesome work by my colleague @byungwoo_bw from @igalia. 馃帀
5
51
6
184
So finally CSS selectors support something like XPath predicates. Only 22 years later and with limited capability. 馃槈
1
1
9
CSS Selectors and XPath were built/optimized around different problems: selectors: given an element and a set of selectors, which selectors match? XPath: given a set of elements and an XPath expression, which elements match?

Mar 21, 2022 路 3:00 PM UTC

1
2
Not entirely -- in XPath you have full expressions (which do what you describe) and also patterns that are doing the same thing as selectors in CSS. And selectors are of course used for generic queries as well outside CSS -- e.g. in document.querySelectAll()
1