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.