nth-child Generator — See Exactly What Matches
Build an :nth-child formula and see which items it selects out of a row.
The an + b formula is evaluated with n counting up from zero, not one, which is why 3n + 1 selects the 1st, 4th and 7th items rather than the 3rd, 6th and 9th. Indexes outside the list simply match nothing, and that is what makes negative steps useful: -n + 3 counts down and selects the first three. :nth-child counts every sibling regardless of type, while :nth-of-type counts only siblings of the same element — a difference that quietly breaks selectors when a heading is added to a list of paragraphs.
Runs in your browser- Privacy
- Runs entirely in your browser — nothing is uploaded
- Cost
- Free, unlimited, no sign-up
Frequently asked questions
Why does 3n + 1 start at 1?
How do I select the first three items?
What is the difference from :nth-of-type?
How to use the nth-child selector generator
- 1Choose the pattern.
- 2Set the a — the step.
- 3Set the b — the offset.
- 4Set the items to preview.
- 5The result appears immediately — copy or download it.
Embed this tool
Put the working nth-child selector generator on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.
Share this tool
Related tools
Last updated
More css generators