Sometimes, we want to select parent element with CSS.
We’ll look at how to select parent element with CSS, in this article.
How to select parent element with CSS?
First we can use the has
pseudo-class, to select parent element with CSS.
For instance, we also write
li:has(> a.active) {
/* styles to apply to the li tag */
}
to select the li that has the anchor element that has the active
class.
To grt the direct children, We use >
.
Conclusion
Lastly, we can use the has
pseudo-class, to select parent element with CSS.