Menu

@supports Lies: When CSS Says 'Yes' but Browsers Say 'LOL No'
🖼️

@supports Lies: When CSS Says 'Yes' but Browsers Say 'LOL No'

DEV Community·Alvaro Montoro·6 months ago
#h15RIuOQ
#comment#css#webdev#software#supports
Reading 0:00
15s threshold

According to the CSS specification, the @supports at-rule must be placed at the top level or nested inside another conditional group at-rule. However, browsers also allow code like this (which, at least in theory, is not valid):

.my-class { @supports ( property : value ) { ... } }

Enter fullscreen mode

Exit fullscreen mode

And that's confusing.

Either browsers should ignore the nested @supports entirely (or always execute it, since browsers are often forgiving with HTML and CSS), or they should apply it relative to the nested-in rule. Applying it as if it were at the root level while visually nesting it inside a selector can be misleading.

Take this example:

li ::marker { @supports ( content : " - " ) { content : " - " ; color : red ; } }

Enter fullscreen mode

Exit fullscreen mode

This works in most browsers. Chrome, Safari, and Firefox support ::marker , and they all support content: " - " .…

Continue reading — create a free account

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