What is CSS nth-of-type?

The CSS nth-of-type(n) selector matches every element of a specific type that is the nthn^{th} child of its parent.

n can be any of the following:

  • number
  • keyword
  • formula.

Syntax

: nth-of-type(number) {
  // css 
}

The code below shows how different stylings can be applied to different paragraphs based on their nth value.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved