concept

nth-child-of-selector-list — CSS reference

Filter siblings by the selector list before applying the one-based formula. Specificity includes one pseudo-class plus the maximum specificity of the filter.

Formal Syntax & Structure

css syntaxcss
:nth-child(An+B of selector-list)

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-child(2 of .notice) { color: rgb(0, 96, 80); }</style></head><body><div><p class="sample notice">First</p><p id="b" class="sample">Unfiltered second</p><p id="a" class="sample notice">Filtered second</p></div></body></html>
CSS Reference