TIL @Supports
POSTED ON:
TAGS: css defensive-coding
Unsupported CSS can break things.
You typically wrap it in a @Supports
rule.
@supports (display: flex) {
.flex-container > * {
text-shadow: 0px 0px 2px blue;
float: none;
}
.flex-container {
display: flex;
}
}
But that's if you KNOW.
What if you don't?
<button>
Send
</button>
<style>
/* The background color won't change on :hover or :focus
because the invalid :touch pseudo-class makes the whole
list invalid */
button:focus,
button:hover,
button:touch {
background: red;
}
</style>
This is where :where()
comes in handy!
The cool thing about :where()
button:where(:focus,
:hover,
:touch,
:smell,
:feel,
:admire) {
background: red;
}
Doesn't break! Love it!
(but also you should fix your rules.)
Here’s what I didn’t know about :where()
Related TILs
Tagged: css