Artboard 16light, inspiration, solution, idea, innovation,Google Sheets iconSwift icon
Published at
Updated at
Reading time
1min

Just parking this CSS snippet on my blog for my future self. ๐Ÿ™ˆ

If you want to select elements only when there's a given number of them, you can use a :nth-last-child() selector combination.

The following selector combination is called a "quantity query".

li:nth-last-child(n+3),
li:nth-last-child(3) ~ li {
  color: red;
}

See it in action below. ๐Ÿ‘‡

Playground
Preview

Related Topics

Related Articles