Re: [csswg-drafts] [css-conditional-5][css-nesting-1] Feature detection for nesting (#8399)

> I agree that authors will likely not write single stylesheets with both nested and un-nested versions of selectors. They'll either, as you say, write the stylesheet without nesting until they no longer care about older browsers, or use a preprocessor and let it emit the un-nested version.
> 
> However, what's reasonable, and should be encouraged, would be:
> 
> ```css
> @import "nested-and-small.css" supports(selector(&));
> @import "not-nested-and-large.css" not supports(selector(&));
> ```
> 
> (or ideally do the equivalent in <link> tags)
> 
> This way the author can use a preprocessor to generate the larger, un-nested stylesheet, but the user of a newer browser doesn't have to pay the download cost.
> 
> While nesting should be detectable via script, we need to be able to feature detect it without script (or UA sniffing) as well.

I suspect once Nesting has critical mass, what will be more common would be this pattern:

HTML:
```html
<link rel=stylesheet href="nested.css">
```

nested.css:
```css

@import "compiled-to-nonnested.css" not supports(selector(&));

/* nested CSS */
```

-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8399#issuecomment-1428345723 using your GitHub account


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

Received on Monday, 13 February 2023 17:23:05 UTC