How to select the CSS parent element?

Sometimes, we want to select the CSS parent element

In this article, we’ll look at how to select the CSS parent element.

How to select the CSS parent element?

To select the CSS parent element, we use the has selector.

For instance, we write

li:has(> a.active) {
  /*...*/
}

to select the li’s that has a elements with the active class.

Conclusion

To select the CSS parent element, we use the has selector.