Is there a CSS parent selector?
li:has(> a.active) → Selects any li that directly contains an a element with the class "active". The parent li will turn red if it has an active link inside it. CSS :has() Example /* Change text color of if it contains an with class "active" */ li:has(> a.active) { color: red; font-weight: bold; } CSS :has() Parent Selector Example The list item containing an active link will turn red. List Item 1 List Item 2 Active Link List Item 3 Normal Link

li:has(> a.active) → Selects any li that directly contains an a element with the class "active".
The parent li will turn red if it has an active link inside it.
CSS :has() Example
CSS :has() Parent Selector Example
The list item containing an active link will turn red.
- List Item 1
-
List Item 2 Active Link
-
List Item 3 Normal Link