Skip to content

CSS Selectors

Position nth-of-type()

About

The :nth-of-type() pseudo-class matches elements based on their position among siblings of the same type.

Second of each type

The selector :nth-of-type(2) matches the second div and the second p element, counting each type separately.

Every other paragraph

The selector p:nth-of-type(odd) matches every odd p element, ignoring other element types when counting.

  • Change the selector to match all even paragraphs instead