Trying to get your head round :nth-child? Me too 🧐
:nth-child(1)
select the first child only
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(even)
select every even numbered element - :nth-child(odd) works in the same way
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(2n+4)
select every second element starting with the fourth
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(3n)
select every third element
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(3n-1)
select every third element starting with the second
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(n+4)
select all but the first three
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-child(-n+4)
select only the first four
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
:nth-last-child(2)
select the second to last element
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8