Member-only story
CSS Tips and Tricks I Used in 2024
Psst! Read it without an account here.
The year is almost over, and with it, another 365 days of jamming my fingers into keyboards has come to pass. This year brought a lot of new CSS features to the table — not the ones I asked for in my 2023 CSS Christmas Wishlist, mind you, but still plenty.
But many of the new features I used this year aren’t just new to the spec, but also new to me. Maybe you’ve been using some of these for eons, but they’ve really helped me this past year, so I figured I should share them with you. Sharing is caring… unless it’s proprietary.
1. :nth-child(n)
This one has plagued me since I was a junior developer, all those many moons ago. .child:nth-child()
is really neat. You can select the 1st, 3rd, 5th, 7th, etc children of an element, like via :nth-child(odd)
or even some crazy formula like..child:nth-child(3n+2)
which makes me feel like a boy wizard when I do that right the first time.