Selectors We Stopped Writing
Some selectors made sense years ago and now only cause trouble.
The list
Browser support is no longer the excuse it used to be. Everything in this post works in every current browser without a fallback.
- IDs for styling
- Three levels of descendant nesting
- Universal selectors inside components
If you only change one thing after reading this, make it the spacing. Consistent gaps make even a rough layout look intentional.
Flat selectors are easier to delete, and deleting is most of maintenance.
Colour is the last thing we add. Getting the structure right in black and white first saves a lot of arguing later.
None of this is new. It is the same advice print designers have given for a century, moved onto screens.
We keep a scratch file of small experiments like this one. Most of them go nowhere, but a few end up in every project.
12 thoughts on “Selectors We Stopped Writing”
Shared this with my students today.
Thanks for reading, glad it helped.
Agreed, this is how we do it too.
Great write-up. Would love a follow-up on the mobile version.
Ha, we had the exact same argument.
The screenshots sold me. Going to rebuild our card grid this weekend.
Tried it in Safari and it works perfectly.
We had the same fight in our team. Sending this to everyone.
Great write-up. Would love a follow-up on the mobile version.
How long did the whole redesign take you?
I would add one thing: check it in dark mode too.
How long did the whole redesign take you?