Re: [csswg-drafts] [css-contain-3][css-anchor-position-1] Containment makes it difficult to use anchor positioning with container queries (#10040)

> Currently, container queries rely on several types of containment: `size`, `layout`, and `style`. This already causes some confusion with authors, when fixed-position elements nested in a container are now _fixed to the container_ rather than the viewport (thanks to layout containment).
> 
> That issue will become much more noticeable when container queries interact with anchor positioning. As currently defined, `layout` and `style` containment will make it impossible for elements to anchor across different containers. I think that will mean:
> 
> * Positioned elements outside a container cannot see anchors inside a container, since `style` containment scopes the anchor name.

Right, it can only see the anchor-name of the container itself given the current spec for anchor-name:

"Anchor names are style-contained, [scoped to a sub-tree](https://drafts.csswg.org/css-contain-2/#property-scoped-to-a-sub-tree)."

> * Positioned elements inside a container cannot use an anchor outside the container, since `layout` containment doesn't allow reference to external layout? (I'm less clear on the interaction here)

Even style containment does that here:

https://drafts.csswg.org/css-contain-2/#property-scoped-to-a-sub-tree

> While these decisions all make sense in terms of 'the promise' that each containment makes, it will cause a lot of problems for users who want to use both container queries and anchor positioning. Authors should be able to use these features without one constantly interfering with the other.
> 
> Since container queries are somewhat abstracted away from containment (we set a `container-type`, and browsers apply containment _as-needed_), I think the only path forward here is defining more subtle and targeted containment rules for container queries. Are there ways that we can relax _how much_ layout and style containment is required to make container size queries work?

The reason why we added style containment for size containers was that generated content for counters and quotes inside the container could affect layout outside the container through intrinsic sizing, which again could affect the size of the size container, which would cause circularities in the layout when counter/quotes styles depended on size query evaluation.

Counters and quotes need to be style contained for size containers.


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


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

Received on Wednesday, 6 March 2024 20:45:27 UTC