The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS nth-of-type ignores classes Re: nth-of-type ignores classes

Chris Coyier

It’s weird but I’m pretty sure this is the standard expected behavior. :nth-of-type doesn’t care about class, it cares about type.

So when this selector is evaluated, it first evaluates the :nth-of-type rule (it’s the right-most) and determines it’s looking for elements with type “a”. Then it finds the odd ones. Then if the odd one has a class of “foo”, it matches. So it’s still operating from it’s original match on all “a”, not “a”‘s limited to .foo.