I am a bit confused about the nth-of-type
pseudo class, and how this is supposed to work - especially as compared to the nth-child
class.
M
Example of HMTL: CSS: Notice that there is no space between the Result:
https://jsfiddle.net/79t7y24x/ Example of HTML: CSS: Notice here that there is a space between the Result: https://jsfiddle.net/o3v63uo7/:nth-of-type
is used to select a sibling of a particular type.
By type I mean a type of tag as in ,
, :nth-child
is used to select children of a particular parent tag without regard to a type:nth-of-type
tag and the pseudo-class
nth-of-type
. li:nth-of-type(odd) { background-color: #ccc; }
:nth-child
tag and the :nth-child
pseudo-classul :nth-child(even) { background-color: red }