Re: [csswg-drafts] [css-cascade-6] A way for <style> elements to scope to their parent element (#6606)

I think this should be resolved by a combination of:

- #7348 [add a `scope()` to the `@import` syntax](https://github.com/w3c/csswg-drafts/issues/7348#issuecomment-1248646574).
- #7349  [`@scope` without root selector scopes to the parent of the owner node, or the containing tree if there's no owner node](https://github.com/w3c/csswg-drafts/issues/7349#issuecomment-1248666611).

The first one there allows scoped imports using `@import` (which we could propose to the WHATWG as an attribute, similar to the proposed `layer` attribute). The second means you can get the desired behavior by using the `@scope` rule in the nested style sheet, without waiting for an HTML attribute:

```css
<div>
  <style>
    /* scoped to the div, since no scope root selector is given */
    @scope { p { color: red; } }
  </style>
  <p>red</p>
</div>
```

Closing this issue as accepted by those resolutions. If we want to work on an additional `scope` attribute for HTML, that will need to happen in the WHATWG rather than the CSSWG. 


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


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

Received on Wednesday, 21 September 2022 17:24:17 UTC