During one of my teaching sessions, I was discussing the nth-child()
pseudo-selector with a student. I posed the question: Can you use the nth-child
selector to target any HTML element? The response I received was negative, as it is not possible to select the root node or the html element itself.
This realization came as a surprise to me, as I had previously believed that it was indeed possible to target the html element using nth-child()
. Could it actually be done? If yes, what would be the correct method?
I am now eager to uncover the truth so that I can confidently provide accurate information to my students without overlooking any potential edge cases.
Your insights would be greatly appreciated.