Categories
JavaScript Answers

How to use CSS selector for targeting only immediate children and not other identical descendants?

Spread the love

Sometimes, we want to use CSS selector for targeting only immediate children and not other identical descendants.

In this article, we’ll look at how to use CSS selector for targeting only immediate children and not other identical descendants.

How to use CSS selector for targeting only immediate children and not other identical descendants?

To use CSS selector for targeting only immediate children and not other identical descendants, we can use the > operator.

For instance, we write

ul > li

to select the li elements that are the immediate children of a ul element.

Conclusion

To use CSS selector for targeting only immediate children and not other identical descendants, we can use the > operator.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.