pseudo-class

:nth-of-type() — CSS reference

Counts only siblings of the same element type from the start. The of selector-list extension belongs to nth-child, not this function.

Formal Syntax & Structure

css syntaxcss
:nth-of-type(An+B)

Working Example

Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }p:nth-of-type(2) { color: rgb(0, 96, 80); }</style></head><body><div><p id="a" class="sample">A</p><span>Spacer</span><p id="b" class="sample">B</p></div></body></html>
CSS Reference