If you're using react or another frontend framework then you really don't need css selectors. Just make plain css classes and dynamically append them to your components. So much simpler. We do this at my current job and it's honestly the easiest time I've ever had with CSS.
How do you solve the kind of problem the article is describing? How do you have a margin on the bottom of every except the last one? Is there a loop for cards with a conditional that doesn't add the margin? I think the declarative language solution they offer is better.
cards.map((card, i) => {
const isLast = i === cards.length - 1
const className = "card" + isLast ? '' : 'card-margin'
return
)}The nice thing about this is you have a full programming language at your fingertips. You could do something with every even card, ever prime number card, etc.