Re: [csswg-drafts] [css-pseudo] Add a ::contents pseudo-element (#2406)

6 years later, this feature has become even more desirable, thanks to container queries.

Container queries, as the name implies, can only query containers. Today this means we often need to add a wrapping DOM element to be able to query it.

With something like `::contents`, we'd be able to query the same element!

```css
.thing {
  container-type: inline-size;

  &::contents {
    @container (width < 20ch) {…}
  }
}
```

This pattern would similarly be incredibly useful for container **style** queries.

```css
button::contents {
  @container style(--variant: cta) {…}
}
```

```html
<button style="--variant: cta">
```

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


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

Received on Thursday, 23 May 2024 14:56:20 UTC