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

> 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!

I have a related use case: wanting to set lengths based on a container’s size, for the container itself.  I tried to do this:

```
#container {
   container-type: inline-size;
   font-size: 3cqw;
}
```

I ended up wrapping the content of the container in a `div` and setting the font size there instead:

```
#container {
   container-type: inline-size;
}
#container div {
   font-size: 3cqw;
}
```

The `div` has literally no other purpose than to make this possible.

@fantasai explained to me that there would be major cascade problems with a pseudo-element like this, but as there are use cases for being able to do things like what @mayank99 and I described, it would be good to have a way to make them possible without adding elements.

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


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

Received on Monday, 10 June 2024 16:04:36 UTC