Preamble

It has been proposed that CSS3 should include a systematic way to let authors detect features and capabilities of the browsers on which their code is interpreted, thus avoiding unfortunate partial rendering of their pages.

In a simple proposed syntax, a single rule set is disabled if any of its contained rules fails and is marked with !supported:

div {
  xn: xv !supported;
  yn: yv;
}

This is probably good enough for a lot of cases, but we might want to disable one rule set because of a failure in another one. One way to do that is to enclose them both in a @supported at-rule:

@supported {
  div.a {
    xn: xv !supported;
  }

  div.b {
    yn: yv;
  }
}

That is also like a media query, so why not use the same syntax?:

@media (supports) {
  div.a {
    xn: xv !supported;
  }

  div.b {
    yn: yv;
  }
}

That has the advantage that an unrecognized media query will fail if not itself supported.

Some have suggested to express what the author requires in the query itself:

@media (supports(xn: xv)) {
  div.b {
    yn: yv;
  }
}

div.a {
  xn: xv;
}

That's more flexible, as the tested feature does not have to be inside the at-rule, but it's also more verbose. The required feature could go outside using the previous syntax if it were named and then referenced by that name:

@media (supports(stuff)) {
  div.b {
    yn: yv;
  }
}

div.a {
  xn: xv !supported(stuff);
}

Can we find use cases for these more sophisticated forms?

Threads

Use cases

These should show a need for certain levels of complexity in the syntax.

Embossed effect

You can create the effect of letters pushed in or out from a surface by giving the text two shadows, one light and one dark. Then you probably would want to set the text colour to match the background. But hold on! — Setting the text colour is an old feature that's almost bound to work, while setting text shadows is a recent feature still not available on some popular browsers. They will make the text completely invisible!

h1 {
  text-shadow: white -3px -3px 3px black 3px 3px 3px;
  background-color: maroon;
  color: maroon;
}

With a feature query, this is easily avoided:

@media (supports) {
  h1 {
    text-shadow: white -3px -3px 3px black 3px 3px 3px !supported;
    background-color: maroon;
    color: maroon;
  }
}