I was working through the third task of the selectors skill test and now I can’t for the life of me figure out why this first solution doesn’t work in formatting the table and this one does.
Any help very much appreciated.
I was working through the third task of the selectors skill test and now I can’t for the life of me figure out why this first solution doesn’t work in formatting the table and this one does.
Any help very much appreciated.
Hi,
In the first example: table > :nth-child(2n)
you’re using the child combinator:
“The child combinator ( >
) is placed between two CSS selectors”
But, the browser implicitly add a tbody
element to wrap the tr
elements. That’s why table > tr
would never match anything.
If you inspect the table with the Dev Tools, you’ll see that we have table > tbody > tr
Hope this helps,
Didn’t know about the tbody
element. Thank you so much. Does this kind of thing come up often in css?
Not so much! But… you’ll come across some weird stuff now and then, it’s part of the fun