Home › Forums › CSS › Why doesn’t nth-child, first-child, blah-child target the child element(s)? › Re: Why doesn’t nth-child, first-child, blah-child target the child element(s)?
In relation to my comments regarding using a space between the class and the pseudo selector (e.g. .something :nth-child(1)) – I shouldn’t have said wrong, just that this would target the first child of all elements under .something. That’s why I think it’s not particularly useful, albeit valid. In my case, let’s say I want to target the first child element of .something, not the first child element of everything else under .something. This is why I used the .something>:nth-child(3) example.
I guess my point is, *-child doesn’t actually have anything to do with the children of the element you’ve prefixed it with, to do that we need a something like ” ” or “>”. That’s why I was asking if there was some deeper meaning to the choice of name for *-child pseudo selectors. As far as I can tell nth-child(3) for example would be better named simply as nth(3), because it’s getting the nth of that element. The fact they are children, appears irrelevant.