DEV Community

Discussion on: CSS :is() fun

Collapse
 
cchana profile image
Charanjit Chana

Thanks for sharing, I've never really looked into using :is() but can see that it's really useful. I was intrigued by the bit about invalid selectors: :is(h1, :a)

I tested it out and it works great in Chrome, but not in Safari (macOS): codepen.io/cchana/pen/NWbmXdJ

But that's not a big deal, same as before you just need to make sure they selectors are correct but thinking about it some more, this is a fantastic way to simplify your CSS! Fairly well supported, definitely something I'm going to look at making use of in the future!

Collapse
 
imcaity profile image
Caity Opelka • Edited

Definitely has its pros and cons, but it's worth tinkering. Also check out :not(), which does the opposite and excludes the selectors passed to it. Cheers!

Collapse
 
cchana profile image
Charanjit Chana

:not() is awesome, I use it all the time! It took me a while to adjust my writing style for CSS to get into the habit vs using something like :last-child instead though