Re: [csswg-drafts] [css-contain][css-overflow] Setting containment on root should not make scrolling impossible (#9003)

This issue is primarily about establishing a root container for the sake of container queries. One possible approach is to change the way `container` properties are applied to root, rather than changing how the `contain` property applies. The container property often applies containment, but not directly - it represents the authors desire for a queryable container.

For style queries, there is no need to establish a container, but it is possible to name containers. Authors establishing a container name on root will expect that their style queries are resolved on the root element. It would not make sense to ignore styles set on the root element, and it's not even clear to me what it would mean to query styles on viewport. So the issue here is also specific to size queries, and any solution we come to should keep other query types (and container names) intact.

With size queries, there are several things that could differentiate a _root element_ container from a _viewport_ container:

1. The viewport size is entirely determined by the client, while the root element size can be changed by author styles (but not contents, since it would be a container)
2. Viewport scrolling is optimized, and has additional functionality, which a scrollable root element can't provide. A root element container would also need to contain scrolling
3. Relative units and custom properties in queries are resolved on the container. the viewport and root element would resolve those values differently in most cases

Point 3 is the primary advantage that authors might get from using size container queries on root, instead of using a media query. The other main advantage of establishing a root size container is simply to have a fallback for container queries that don't find any intervening containers. 

In my experience, it is very common for authors to set a viewport-based `height` on the root element (eg `100vh` or `100%`), and very _uncommon_ for authors to set a `margin` on root. Because of that, the root container is generally either content-sized (which would not be possible when it's a container) or it is viewport-sized. When establishing a root container, authors are even more likely to set the size of the element based on the size of the viewport. Losing the ability to measure the root element is not a big loss in most cases.

Is there any possible solution here that allows scrolling on the viewport, while continuing to support value resolution (and container names) on the root element? Even if it means we always return the viewport size on root containers?

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


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

Received on Wednesday, 16 August 2023 16:51:26 UTC