Adding “feature X is unsupported” warnings in your CSS Demos with @supports


Great tip from tuts+:

When your CodePen demos rely on cutting edge CSS it’s a good idea to warn people. Let’s provide a notification when browsers don’t support our demos, using the @supports rule to make a handy reusable CodePen asset.

New to Feature Queries (e.g. @supports)? Using Feature Queries in CSS will get you started.

The trick is to add a warning using ::after, and then hide it when @supports indicates the feature is supported. Like this:

/* CSS Grid */
.support-grid::after {
    content: "😢 Sorry, CSS Grid is unsupported in your browser.";

@supports (display: grid) {
  .support-grid::after {
    display: none;

Here’s a demo pen:

See the Pen CSS Grid Layout: Fluid Columns and Better Gutters v by Envato Tuts+ (@tutsplus) on CodePen.

Quick Tip: Add a @supports CSS File to Your CodePen Demos →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.