#todayilearned

by @jm3 · aka John Manoogian3

Frequent, bite-size mini-milestone updates as I fast-forward merge* my front-end web development skills up to 2019 levels. Learn more

nth-last-child(num) - the reverse (Polish) selector

Posted at — Jun 2, 2019

Ever needed to select the last element, or select by counting backwards from the last element?!

*Ricky Jay voice* I HAVE.

The nth-last-child() selector will do that with style.

/* select the -3rd (third from last) div  */
div:nth-last-child(3) {
  ...
}

Click the “CSS” button below: