Menu

1 / 2

Pseudo-classes :is() and :where() for clean code

DEV Community·Nick Benksim·6 months ago
#Ct34Vmws
#css#webdev#frontend#programming#specificity
Reading 0:00
15s threshold

Stop Repeating Yourself: The Magic of :is() and :where()

Picture this: you are working on a massive dashboard. You need to apply the same margin and font-weight to headings inside your header, sidebar, and footer. You end up with a selector list that looks like a grocery receipt from a very hungry giant. It’s ugly, it’s hard to read, and if you make a typo in one part of that comma-separated list, some browsers might discard the entire rule. We are in 2026, and our CSS should look as smart as the logic we write in our TypeScript files.

Enter :is() and :where() . These two functional pseudo-classes are the secret weapons for anyone tired of writing redundant selectors.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.