Re: [csswg-drafts] [css-cascade-6] Strong vs weak scoping proximity (#6790)

Also note: both 'proximity' and 'lower boundaries' rely on the ability to define a single element as _the_ 'scoping root' for a given matched selector. That construction of explicit DOM fragments with singular roots is the big technical distinction between scope and nesting – and is a complicated concept to embed as part of existing selectors. Even at this point making `>>` work relies on doing that _implicitly_.

While we want people to use layers for managing specificity, we did that in part by making layered styles _less important than unlayered styles_. Meanwhile, we encourage authors to _layer all styles_. During that transition, authors are likely to find old unlayered styles that don't work well in the new layered setup – especially styles using `!important`. 

I know the analogy isn't exact, but for me, this feels like a similar choice. Authors should be encouraged to use scopes rather than nesting when narrowing selector relationships. Selectors don't easily express that new concept, but an at-rule can do it fairly elegantly. And, if authors begin to use scopes consistently, all their selector specificities go down by default - something authors have wanted for a long time. And the fallback from specificity improves at the same time. They are opting into a new system, with a clear new syntax, where specificity is used more sparingly. Meanwhile, as Tab suggests, nesting is syntax sugar for constructing the complex or compound selectors that are still needed inside those scope blocks (as Keith mentioned). And specificity continues to work across scopes in the way authors are used to.

Yes, using nesting to do pseudo-scopes would be more 'powerful' - and that's a reason authors will prefer scope in a lot of cases. In the same way that authors should avoid unlayered styles when using layers. I see it as a bonus to give authors more ways to _decrease_ the cascade weight of individual selectors _by default_, so they can increase that weight more intentionally when it's actually warranted.  

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


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

Received on Wednesday, 1 March 2023 21:33:40 UTC