[csswg-drafts] Need a way in CSS to test for support of HTML features (#9746)

jensimmons has just created a new issue for https://github.com/w3c/csswg-drafts:

== Need a way in CSS to test for support of HTML features ==
There should be a way to feature detect support for an HTML attribute, HTML element and other things in HTML. 

For instance, the `switch` attribute is new to HTML. It turns a checkbox form control into a native switch, in a progressively enhanced fashion.

Authors will likely want to style their switch with custom styles, while still supporting the checkbox fallback. If they apply styles without writing conditional code, the checkbox is ruined. 

This is one idea of how it could work...
```
@supports selector(input[switch]) {
 /* Would like to put custom switch styles here, so they only apply conditionally. */
}
```
...but that doesn't work... because it always returns true. The selector is understood by CSS, even when it's not supported in HTML. 

How can we provide a mechanism to CSS for testing support of HTML features?

Here's a demo of switch, with custom styles that should be applied conditionally. 
https://codepen.io/jensimmons/pen/eYXYZWr?editors=1100

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9746 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 21 December 2023 21:56:22 UTC