The :nth-child()
is a CSS pseudo-class selector that allows you to select elements based on the index (source order) inside their container.
A pseudo-class selector selects content based on its relationship with parent and sibling elements.
The :nth-child()
takes only one argument as its input:
Additionally, we can specify the HTML element whose child we want to select through the :nth-child()
method. If no such element is specified, then the :nth-child()
method applies the input argument to all the elements in the HTML.
The following examples demonstrate different arguments passed to the :nth-child()
method.