Re: [csswg-drafts] [css-sizing] Should `contain-intrinsic-*: from-element` require `contain:size`? (#13182)

To explain my opposition to size containment in more detail:

 - `contain-intrinsic-size` only applies to elements with size containment, as implied by the name. I think it would be very confusing to add an exception for this.
 - It can seem fine, then, to require the author to use an explicit `contain: size`, or maybe the UA could trigger size containment automatically on iframes.
 - However, when an element has size containment, changes in the descendant elements (if non-replaced) or loaded resource (if replaced) should not affect its intrinsic size, otherwise [this optimization](https://drafts.csswg.org/css-contain-2/#containment-size-opt) wouldn't be possible:
   > When the style or contents of a descendant of the [containment box](https://drafts.csswg.org/css-contain-2/#size-containment-box) is changed, calculating what part of the DOM tree is "dirtied" and might need to be re-laid out can stop at the containment box.
 - I guess the spec already tries to address this in https://drafts.csswg.org/css-sizing-4/#internal-layout-intrinsic-size
    > When an [iframe](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element)’s internal document is loaded, if the required [meta](https://html.spec.whatwg.org/multipage/semantics.html#meta) element is present at the time of the DOMContentLoaded and load events, the [iframe](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element)’s internal layout intrinsic size’s height is set to the [natural height](https://drafts.csswg.org/css-images-3/#natural-height) of the embedded document. Subsequent changes to content, styling or layout of the embedded document do not affect the internal layout intrinsic size.

    However,
    - What happens if the iframe navigates to a different embedded document? Can the internal layout intrinsic size survive that? I don't think authors will expect it to survive, but if it changes, then that defeats size containment.
    - What happens while the iframe is loading and the internal layout intrinsic size has not been set yet? Again, if when the internal layout intrinsic size is finally set, this affects the intrinsic size of the iframe, then that defeats size containment.

So I think it's better to use a different property.

About the proposal above I'm not sure if it's very clear that `<length [0,∞]>` is just a fallback. Another idea could be

```
iframe-intrinsic-height: auto? <length [0,∞]>
```

where a length alone just sets the intrinsic height to that amount (the initial value would be `150px`). And `auto` means that we want to take the intrinsic size from the contents, with the length just being the fallback (somewhat analogous to `aspect-ratio: auto <ratio>`).


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


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

Received on Thursday, 22 January 2026 16:13:43 UTC