:nth-child()
noun
say it: “KOH-lun ENTH CHYLD” /ˈkoʊlən ɛnθ tʃaɪld/ or “ENTH CHYLD” /ɛnθ tʃaɪld/
A pseudo-class that picks elements by their position among their siblings: :nth-child(odd) for every other one, :nth-child(3) for the third, :nth-child(3n) for every third.
What does :nth-child() do?
:nth-child() picks children by position: a number, odd, even, or a pattern like 3n for every third one.
tr:nth-child(even) { background: #f5f5f5; } /* striped table rows */
In a sentence
- “With :nth-child() and the word odd in its parentheses, every other row of the high-score table turned light gray.”
Level: Apprentice · More CSS terms at this level
Updated