Re: [csswg-drafts] [css-cascade] Allow making a scope's upper bound really inclusive (check nested selectors against it) (#13391)

This is more about how relative selectors work.

> By default, selectors in a scoped style rule are relative selectors, with the scoping root and descendant combinator implied at the start. 

https://drafts.csswg.org/css-cascade-6/#scoped-rules

----

Something like `@scope including (.my-design-system)` would still need a definition of a scoping root that makes sense for relative selectors.

This scoping root would still have the implicit behavior of relative selectors:

```css
@scope including (.my-design-system) {
  :special-scoping-root .bg-primary {}
}
```

This wouldn't be different from:

```css
@scope (:has(> .my-design-system)) {
  .bg-primary {}
}
```

Which doesn't really work as you want:

```html
<div>
  <div class="my-design-system bg-primary">
  </div>
  
  <div class="bg-primary">
    unrelated, but also selected
  </div>
</div>
```

----

Some new selector would slot in more nicely with existing features:

```css
@scope (.my-design-system) {
  :in-scope.bg-primary { background-color: var(--ds-bg-primary); }
}
```

Where `:in-scope` would make the selector non-relative


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


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

Received on Sunday, 25 January 2026 08:41:17 UTC