When you want to select
the 7th element of its
type within its parent, or
select the first 15 elements or
every 3rd element and so on,
you can use the :nth-of-type
pseudo-class:
In the following example,
we want to float
every
second link within the div
to the right:
Using :nth-child
here will
not get the desired results.
Try using these in the example above:
:nth-of-type(n+2)
- Selects all elements of the type starting from the 2nd one
:nth-child(3n)
- Selects every 3rd element of the type
:nth-child(3n-2)
- Selects every 3rd element of the type starting from the first one