Today I Learned - Rocky Kev

TIL @Supports

POSTED ON:

TAGS:

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:

TIL the alternate keyword

If 'alternate' appears along with the stylesheet keyword, the linked file is an alternative stylesheet. It won’t be applied to the document, but it will be ready for when we need it.

TIL Logical Properties

For that sweet sweet Internationalization you want to avoid directional words like 'left', 'right', 'top', and 'bottom'.

TIL Using pseudo-classes in your querySelector!

let notTuna = document.querySelectorAll('.sandwich:not(.tuna)')