Re: [csswg-drafts] Allow applying style rules to the container itself (especially with style querries) (#10744)

This has some overlap with [my proposal to add an `@element` at rule](https://github.com/w3c/csswg-drafts/issues/10509).

I agree that needing to create otherwise useless elements in markup, purely for style queries is an anti-pattern.

Maybe even both proposals are useful for subtly different cases?

### `@element`

```css
@element style(--color: pink) {
  .foo {
    background-color: pink;
  }
}
```

`.foo` matches **elements** with class `.foo` and a custom prop `--color` with value `pink`

### `:container`

```css
@container style(--color: pink) {
  :container {
    background-color: pink;
  }
}
```

`:container` matches **containers** with a custom prop `--color` with value `pink`



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


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

Received on Friday, 16 August 2024 10:12:57 UTC