Categories
CSS

How to select the CSS parent element?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *