Artboard 16light, inspiration, solution, idea, innovation,ionicons-v5_logosGoogle Sheets iconSwift icon
Published at
Updated at
Reading time

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(3) ~ li {
  color: red;

See it in action below. ๐Ÿ‘‡

Was this snippet helpful?
Yes? Cool! You might want to check out Web Weekly for more snippets. The last edition went out 14 days ago.

Related Topics

Related Articles