Skip to content

CSS Selectors

Position nth-child(n)

About

The :nth-child() pseudo-class supports a counter variable n which starts at 0 and increments by 1 for every element.

The first result is 3n = 3 * 0 = 0 which doesn't match any element (because the first element is 1). The second result is 3n = 3 * 1 = 3 which matches the third element in the list.

Every third child

The selector :nth-child(3n) matches every third child of its parent. The selector supports the + and - operators to offset the counter variable.

  • Adjust the selector to start with the first element and then every third element