There is currently no way to select the parent of an element in CSS, at least not a way that works across all browsers.
If there was a way to do it, it would be in either of the current CSS selectors specs:
- Selectors Level 3 Spec
- CSS 2.1 Selectors Spec
That said, the Selectors Level 4 Working Draft includes a :has()
pseudo-class that will provide this capability. It will be similar to the jQuery implementation.
li:has(> a.active) { /* styles to apply to the li tag */ }
However, as of 2022, it is only supported by Safari.
In the meantime, you’ll have to resort to JavaScript if you need to select a parent element.