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)
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!
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!
: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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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!
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!
: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