Re: [csswg-drafts] [css-sizing] Auto-resize iframes based on content (#1771)

The CSS Working Group just discussed `[css-sizing] Auto-resize iframes based on content`, and agreed to the following:

* `RESOLVED: The first instance of the meta tag for this feature is immutable once parsed`
* `RESOLVED: Define frame-sizing with various height and with keywords, with default of auto`

<details><summary>The full IRC log of that discussion</summary>
&lt;koji> https://github.com/w3c/csswg-drafts/issues/1771#issuecomment-3607718468<br>
&lt;bramus> koji: want to discuss chris’s comment on the issue<br>
&lt;bramus> … looking for feedback on most recent ED<br>
&lt;lwarlow> q+<br>
&lt;bramus> … if anyone has feedback, we’d appreciate<br>
&lt;bramus> astearns: has anyone had a chance to look into this ED?<br>
&lt;bramus> … seeing some heads shaking<br>
&lt;bramus> … koji, would you like this to be “PTAL” and move on to the rest, or want to summarize the changes?<br>
&lt;bramus> koji: I believe Chris already asked a few weeks ago.<br>
&lt;emilio> q+<br>
&lt;bramus> … if anyone has anything, or wants more time …<br>
&lt;bramus> iank_: can do a high level overview, if that would be helpful<br>
&lt;oriol> q+<br>
&lt;bramus> … basically, this is trying to sovle the problem of having iframes grow based on their contents<br>
&lt;bramus> … now due to the way they work, this is somehwat difficult (cycles)<br>
&lt;bramus> … what this does, is  you need to opt in both sides<br>
&lt;bramus> … meta tag in the iframe<br>
&lt;bramus> … and then from the parent side you opt-in via contain-intrinsic-size<br>
&lt;bramus> … at the moment, what happens is the that the scroll height repalces the natural size on the parent<br>
&lt;bramus> … and then replace-siziung happens as normal<br>
&lt;bramus> … that message, at the moment, happens on DOMContentLoaded<br>
&lt;bramus> … (exact timing can be discussed)<br>
&lt;bramus> … dont want to do this every time the scroll changes<br>
&lt;bramus> s/scroll/scrollheight<br>
&lt;bramus> … other mechanism is via script inside of the iframe<br>
&lt;bramus> … iframe loads content dynamically (e.g. a comment widget) and then fires event upwards<br>
&lt;bramus> … window.requestResize<br>
&lt;bramus> … that is high level overview<br>
&lt;bramus> … open questions are:<br>
&lt;bramus> … What CSS property triggers this? c-i-s or new one?<br>
&lt;bramus> … subissue is that we currently have it hooked up to height … want to opt in to only 1 dimension, 2 is tricky … but maybe you want both?<br>
&lt;emilio> q+<br>
&lt;bramus> … next thing is about the timing: script for dynamic use-case, but what is most useful timing for doing it automatically<br>
&lt;bramus> koji: Yes, looking for feedback on the property name<br>
&lt;bramus> … whether `contain: size` is required or ont<br>
&lt;bramus> … want to also minimize the number of ???<br>
&lt;bramus> … whether it is OK for the meta tag be mutable<br>
&lt;bramus> iank_: that should be fine<br>
&lt;astearns> ack lwarlow<br>
&lt;bramus> lwarlow: does this work for cross=-origin iframes? or only same-origin?<br>
&lt;bramus> koji: also cross-origin<br>
&lt;bramus> lwarlow: is that not a new comms mechanism?<br>
&lt;bramus> koji: are you talking about privacy concerns?<br>
&lt;bramus> lwarlow: yes, from users end :… the two props opting in seems fine, but cross-channel comms<br>
&lt;bramus> iank_: you already have that<br>
&lt;bramus> … the parent can change the size and that is that direction<br>
&lt;bramus> emilio: but it is not ???<br>
&lt;bramus> iank_: like a resizeobserver?<br>
&lt;bramus> emilio: right now you need to postmessage<br>
&lt;bramus> iank_: from my persepective this isnt adding anything new in comms terms … already exists from both sides<br>
&lt;bramus> lwarlow: fair enough<br>
&lt;bramus> … as its opt-in<br>
&lt;bramus> lwarlow: I think cross-origin is the most interesting use-case here<br>
&lt;bramus> iank_: yes<br>
&lt;bramus> astearns: if there is an opt-in for not allowing post-message, this should also cover this?<br>
&lt;bramus> iank_: that is the policy with the meta, to say that they are OK with broadcasting the info<br>
&lt;astearns> ack emilio<br>
&lt;dholbert> q+<br>
&lt;bramus> emilio: regarding timing … feels simliar tlike scrolltoref code<br>
&lt;bramus> … in gecko that is also DOMContentLoaded and Load<br>
&lt;bramus> … matches what is being proposed, but might have some subtleties<br>
&lt;bramus> … seems worth being consistent<br>
&lt;bramus> … roughly around the same time as scrolltoref algo<br>
&lt;bramus> iank_: does that sound reasonable, koji?<br>
&lt;bramus> koji: not familar with that part of the code<br>
&lt;smfr> q+<br>
&lt;bramus> emilio: domcontentloaded is the earliest event, and load is the latest where you can know it … would be good to double check<br>
&lt;bramus> iank_: was there 1 other case where we trigger this automatic thing?<br>
&lt;bramus> koji: just the two events mentioned<br>
&lt;bramus> … can I confirm that emilio to mirror scrolltoref?<br>
&lt;bramus> iank_: emilio is saying to be consistent with it, timing-wise<br>
&lt;bramus> emilio: same assumption that we are making: scrollheight will be right at those events and time<br>
&lt;astearns> ack oriol<br>
&lt;bramus> oriol: dont think this should be bolted on top of size containment, so prop should not be c-i-s<br>
&lt;bramus> … should c-i-s surive when the iframe navigates to other document<br>
&lt;bramus> iank_: I would expect no<br>
&lt;bramus> emilio: there is precedent for this: svg img in object that auto-size, it also goes away when you navigate out<br>
&lt;TabAtkins> I also would expect no, we'd revert it to the default size (unless the new page also opts in)<br>
&lt;bramus> iank_: makes sense<br>
&lt;bramus> … good food for test case<br>
&lt;bramus> smfr: so what happens to the iframe when you navigate?<br>
&lt;bramus> emilio: it might get clobbered by the next thing<br>
&lt;bramus> smfr: if the next thing has the meta tag?<br>
&lt;bramus> iank_: it loses the natural size<br>
&lt;astearns> ack dholbert<br>
&lt;bramus> dholbert: sounds like sth an author could polyfill with postmessage<br>
&lt;emilio> q+<br>
&lt;bramus> … as content loads, incremental updates<br>
&lt;bramus> … sounds like that would likely paint inside the smaller iframe size, and then the iframe would grow<br>
&lt;bramus> iank_: yes, cross-origin different ???<br>
&lt;bramus> … impl could frame block for a few frames<br>
&lt;astearns> ack smfr<br>
&lt;bramus> dholbert: but not part of the design<br>
&lt;bramus> smfr: domcontentloaded feels too early<br>
&lt;bramus> … load … that would be the rendering event _after_ the load<br>
&lt;bramus> emilio: scrolltoref happens before the update, so you can see the scroll<br>
&lt;bramus> smfr: but if th econtent mutates after the<br>
&lt;bramus> iank_: there is a task that gets ???<br>
&lt;bramus> emilio: if its a task then you could render in-between<br>
&lt;bramus> iank_: &lt;missed><br>
&lt;bramus> smfr: I can see this being used on payment flow, that typically has multiple navigations<br>
&lt;bramus> … seems like a hard thing for impl to do<br>
&lt;astearns> s/&lt;missed>/so we’ll take this as an action to precisely specify timing/<br>
&lt;bramus> emilio: if you have intrinsic height, the navigation would clobber it but only at the point the next page is domcontentloaded/load<br>
&lt;bramus> … seems like less opportunities fro jumping around<br>
&lt;dholbert> s/multiple navigations/multiple navigations where the payment-flow provider would have to take care to specify the meta tag at each point to avoid the iframe resizing/<br>
&lt;bramus> smfr: is there experience with this so far?<br>
&lt;bramus> iank_: a lot of the payment markets do navigate a lot<br>
&lt;bramus> … maybe we clear the natural size, and get feedback from authors and can re-evaluate<br>
&lt;astearns> likely should have a navigation example in the spec<br>
&lt;bramus> smfr: so if you do navigate, you keep the old size you keep the old size until the domcontentloaded or snap back to 0?<br>
&lt;bramus> iank_: not to 0 but default object size<br>
&lt;bramus> … (I think)<br>
&lt;bramus> koji: current code does not do anything right now … upon navigation we keep current size, and then on next domcontentloaded it resized<br>
&lt;bramus> iank_: we may be accidentally doing what smfr is suggestions<br>
&lt;bramus> smfr: so new doc might have info about previous doc<br>
&lt;bramus> … needs more thinking<br>
&lt;bramus> iank_: needs follow up issue<br>
&lt;bramus> fantasai: if the prvious and next do are ont he sam eorigin, this is fine<br>
&lt;bramus> iank_: technically this already exists if you polyfill this via postmessage<br>
&lt;bramus> emilio: but the top level page needs to coordinate<br>
&lt;lwarlow> q<br>
&lt;bramus> fantasai: but in this case it is less likely that the author will know<br>
&lt;fantasai> They might do it unintentionally<br>
&lt;bramus> iank_: will fill isssue and follow-up<br>
&lt;fantasai> Just because they want the sizing behavior<br>
&lt;astearns> ack dbaron<br>
&lt;bramus> dbaron: wanted to react about scrolltoref timing: feel like that timing is bad tha twe have built new platform features that work around ???<br>
&lt;bramus> emilio: maybe we should make it better<br>
&lt;dholbert> s/???/how bad it is/<br>
&lt;bramus> dbaron: if ?? made it better … i would be hesitant to mirro rscorlltoref timing<br>
&lt;bramus> emilio: it is doing the same thing. like scroll-anchoring is keeping the scroll pos … if you do this thing … this issue has same features. if somebody add image after load<br>
&lt;bramus> dbaron: am suggesting that scorlltoref is too infrequent<br>
&lt;dholbert> s/after load/after load, then the image will overflow/<br>
&lt;bramus> … and scrolltoref+scrollin gtiming is like more useful<br>
&lt;bramus> emilio: but then you get into that cyclic issue we are trying to prevent<br>
&lt;bramus> dbaron: yes, missed the cyclic issue<br>
&lt;bramus> emilio: every time scrollheight grows, then re-rerunning would cause cycles<br>
&lt;bramus> … that is why a pretty infrequent timing is proposed<br>
&lt;bramus> iank_: needs an affixed number of times this gets invoked<br>
&lt;astearns> ack emilio<br>
&lt;bramus> emilio: doing thi sin both axis seems useful<br>
&lt;bramus> … web extension folks often complain about popover sizes being incompatible across browsers<br>
&lt;bramus> … we have code in gecko to autosize<br>
&lt;bramus> … should not do this to begin with, but is possible<br>
&lt;bramus> iank_: was trying to avoid both axis at the same time, as every browser does auto=sozing differently (we do min-content)<br>
&lt;bramus> emilio: we do ???<br>
&lt;bramus> iank_: gets more broken if you do orthogonal writing modes<br>
&lt;bramus> … there is a few different things you can do:<br>
&lt;bramus> … - scrollheight seems easiest<br>
&lt;bramus> … - html height could also be considered<br>
&lt;bramus> … I think scorllheigt is most useful<br>
&lt;bramus> emilio: i agree<br>
&lt;bramus> iank_: what about orhtogoanl layouts?<br>
&lt;bramus> … scrollwidth is easiest<br>
&lt;bramus> … (most logical)<br>
&lt;bramus> … both axis … I dont anyone uses scrollwidth/scrollheight for that<br>
&lt;bramus> … I would like to punt the both axis case, and do one or the other initially<br>
&lt;bramus> … but if you really know what you are doing, but the guardrails are less on that<br>
&lt;bramus> emilio: fine with punting<br>
&lt;bramus> … but saying you could design the feature to have it solved in the future<br>
&lt;bramus> … especially for web content<br>
&lt;Kurt> q+<br>
&lt;bramus> iank_: it is basically a request to update the sizes<br>
&lt;bramus> emilio: maybe someone should opt in to one of the sizes<br>
&lt;bramus> iank_: and this gets into the next issue … whatever this prop will be … like from-width, from-height, …<br>
&lt;bramus> … or from-scroll-width (and logical ones)<br>
&lt;bramus> … would be how I could design it<br>
&lt;bramus> emilio: makes sense<br>
&lt;bramus> … brought it up to not block it<br>
&lt;bramus> … ideally, extension popups do this weird thing with RO<br>
&lt;bramus> … if the popup could just request an auto size, that would solve that<br>
&lt;bramus> iank_: popup stuff would most likely require a few passes<br>
&lt;astearns> ack fantasai<br>
&lt;bramus> fantasai: if we do solve both axis, we could use a new keyword with width and height<br>
&lt;bramus> … if not, we could use frame-sizing<br>
&lt;bramus> … was for what to measure: alternative is scrollable content area<br>
&lt;astearns> s/frame-sizing/frame-sizing since we have form-sizing/<br>
&lt;bramus> … that wont grow if you have things animating in or out<br>
&lt;bramus> … like basically the in-flow scrollable area<br>
&lt;bramus> iank_: that is equicalent to the html size<br>
&lt;bramus> fantasai: for the height yes, not width<br>
&lt;bramus> … html is always as wide as the ICB<br>
&lt;bramus> … but content scrollable area …<br>
&lt;bramus> … would need to look into that<br>
&lt;bramus> … not a useful definition<br>
&lt;bramus> … breaks the ??? principle<br>
&lt;fantasai> s/???/div transparency/<br>
&lt;bramus> iank_: reason why I was OK with scrollheight was bercause it is effectively a one shot<br>
&lt;bramus> … the scrolalble area: people might but height: 100% on HTML and overlfowing body, so we wont capture that<br>
&lt;bramus> fantasai: triggering measurement on the load event and stuff makes sense<br>
&lt;bramus> … having an API also makes sense<br>
&lt;bramus> … but other cases (like expanding accordion): could make details opening and closing a trigger could be useful here<br>
&lt;bramus> iank_: might be OK<br>
&lt;bramus> … should maybe be part of the meta tag, to have folks opt-in<br>
&lt;bramus> … by default domcontentloaded and load, and then add more optoins<br>
&lt;bramus> fantasai: some things like details should maybe be default, and then opt out<br>
&lt;bramus> emilio: I think problem is that it not easy determing when you want to compute the size … details migth be a sidebar and stuff might have move in between … so might be bad that you recalced<br>
&lt;bramus> iank_: it would snap again for no obvious reason<br>
&lt;bramus> … have done similar thought process, to do it – for example – on network events, but comes bad user experience<br>
&lt;bramus> emilio: like style sheet lods<br>
&lt;bramus> iank_: yes. mimimum useful is domcontentloaded and load + the scrip hammmer<br>
&lt;bramus> … additional opt-ins can be considered<br>
&lt;astearns> ack Kurt<br>
&lt;Kurt> https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/view<br>
&lt;bramus> Kurt: edge case thing: If you have SVG in an iframe, the view element can specificy the viewbox and the fragment URL can take different values, which should trigger a resize as well? It’s a URL chagne without a navigation<br>
&lt;bramus> iank_: can file an issue for that case<br>
&lt;bramus> astearns: currently past the first bullet of the three in the issue<br>
&lt;bramus> … should we discuss mutability?<br>
&lt;bramus> iank_: I think we discussed that and it should be immutable<br>
&lt;bramus> astearns: should we take a resolution?<br>
&lt;bramus> astearns: PROPOSED RESOLUTION: The meta tag for this feature is immutable<br>
&lt;bramus> smfr: from the beginning of time, or snapshotted at DCL?<br>
&lt;bramus> koji: Only by parser<br>
&lt;bramus> smfr: if it is multiple: first or last?<br>
&lt;TabAtkins> "first" is immutable<br>
&lt;bramus> iank_: we will document it<br>
&lt;fantasai> +1<br>
&lt;bramus> … and come back to that if its a bad idea<br>
&lt;TabAtkins> so yeah, when parser either hits the first &lt;meta> of this type, or closes the &lt;head>, it should consider the value frozen.<br>
&lt;TabAtkins> imo<br>
&lt;bramus> astearns: amened resolution is that the first meta tag immutable once parsed<br>
&lt;lwarlow> +1<br>
&lt;bramus> RESOLVED: The first instance of the meta tag for this feature is immutable once parsed<br>
&lt;bramus> koji: can we also resolve on contain: size?<br>
&lt;bramus> astearns: next issue is about c-i-s require contain: size<br>
&lt;oriol> Does document.write count as parsed?<br>
&lt;bramus> … is that same thing?<br>
&lt;bramus> iank_: I think we want to change the property and not ??<br>
&lt;iank_> `frame-sizing: content-width | content-height | content-block-size | content-inline-size | none`<br>
&lt;bramus> … resolve that its a new property named frame-sizing<br>
&lt;bramus> … and then TBD the keywords<br>
&lt;emilio> q+<br>
&lt;bramus> koji: and we also need a default<br>
&lt;bramus> iank_: that would be none<br>
&lt;bramus> koji: I mean a default size before receiving the first<br>
&lt;bramus> emilio: maybe we can explain the object svg sizing with this keyword?<br>
&lt;bramus> … was thinking: is it useful to explain svg, but maybe no because you can override it<br>
&lt;bramus> … mabye dont need that<br>
&lt;koji> `frame-sizing: [content-width | content-height | content-block-size | content-inline-size | none] &lt;lenght>?`<br>
&lt;bramus> fantasai: are these keywords using the writing of the embedding iframe or of the embedded dcoucment<br>
&lt;bramus> iank_: of the parent<br>
&lt;bramus> emilio: other question is: would this apply when you have an SVG doc embedded?<br>
&lt;bramus> … in that case, if the default is none, its weird<br>
&lt;bramus> … so maybe should be auto<br>
&lt;bramus> dholbert: is the scrollheight interesting with an SVG doc?<br>
&lt;bramus> … even if the SVG declares a large size, if you put in an iframe that size would be respected<br>
&lt;bramus> … (at least large viewbox)<br>
&lt;bramus> ChrisL: the viewbox is irrelevant to the size if you declare a<br>
&lt;fantasai> frame-sizing: fixed | ...<br>
&lt;bramus> emilio: maybe default to  auto<br>
&lt;bramus> iank_: can file an issue about how SVG docs should work<br>
&lt;bramus> astearns: so elika,. you suggested fixed<br>
&lt;bramus> fantasai: because field-sizing uses fixed and content<br>
&lt;bramus> … if its auto then it should be auto, but if its none then it should be  ???<br>
&lt;bramus> … if you put SVG in an iframe, does it size the same as ??<br>
&lt;astearns> s/???/fixed instead/<br>
&lt;bramus> iank_: it has a full document<br>
&lt;bramus> emilio: but a subdocument<br>
&lt;bramus> fantasai: will it size to its content<br>
&lt;bramus> emilio: it gets the aspect ratio form the doc<br>
&lt;oriol> q+<br>
&lt;bramus> iank_: can take an issue for that<br>
&lt;astearns> ack emilio<br>
&lt;bramus> fantasai: and dpeending on that do auto or fixed<br>
&lt;bramus> iank_: can do auto initially<br>
&lt;astearns> ack oriol<br>
&lt;bramus> oriol: got lost about what auto is supposed to address<br>
&lt;bramus> iank_: trhing to cover the svg-in-iframe<br>
&lt;bramus> emilio: it is s the apsect ratio<br>
&lt;bramus> oriol: svg in iframe has special treatment?<br>
&lt;bramus> emilio: yes, svg propagates ar to the embedder<br>
&lt;kizu> Random semi-related fun article about SVG and sizing, where it exploits streaming SVG with animations to continuously update its size: https://dev.to/janeori/100-css-fetch-and-exfiltrate-512-bits-of-server-generated-data-embedded-in-an-animated-svg-5aad, could be an interesting edge case to consider.<br>
&lt;bramus> Kurt: and that ar can change on the url fragment<br>
&lt;astearns> `frame-sizing: [content-width | content-height | content-block-size | content-inline-size | auto] &lt;length>?`<br>
&lt;bramus> astearns: we are definitely gonna need an issue for<br>
&lt;bramus> … that<br>
&lt;bramus> astearns: is this the syntax I posted?<br>
&lt;bramus> fantasai: are we including length, or reusing some other?<br>
&lt;bramus> iank_: problem with throwing length in there is that you need contain: size, which would make us ignore this property<br>
&lt;bramus> … maybe can specify like c-i-s without contain: size but would be weird<br>
&lt;fantasai> PROPOSED: Define `frame-sizing: auto | content-width/height/block-size/inline-size` to define which axis draws from the iframe content. Rename auto to fixed if SVG is not magical enough to require auto.<br>
&lt;bramus> … using koji’s suggestion to putting default in here would make sense from that perspective<br>
&lt;bramus> fantasai: so we …<br>
&lt;bramus> iank_: so c-i-s needs contain: size, and contain: size will make you ignore all of the content … so its 0 or c-i-s value. If you set frame-sizing (like field-sizing) to content might not do anyting if you have those other two<br>
&lt;bramus> … problem is that cis requires c:s and you cant use cis with the new prop<br>
&lt;oriol> +1<br>
&lt;bramus> … unless we make it work when you get ???<br>
&lt;bramus> fantasai: we could say that it has no effect if you have either contain or frame-sizing<br>
&lt;bramus> … would rather do that, than introduce othe rproperty<br>
&lt;bramus> iank_: concern is that it has c-i-s in the name<br>
&lt;bramus> fantasai: maybe rename it<br>
&lt;bramus> iank_: fine with reusing that<br>
&lt;oriol> q+<br>
&lt;bramus> koji: in this issue oriol said ???<br>
&lt;astearns> ack oriol<br>
&lt;bramus> oriol: it has contain in the name, so it should only be for size containment, dont like the idea of using it for this also. little overlap that I would prefer including into frame-sizign<br>
&lt;koji> s/???/should require not contain:size<br>
&lt;koji> s/???/should require not contain:size/<br>
&lt;bramus> fantasai: I can see why you woulnt want to shove the length in the sam eproperty<br>
&lt;bramus> iank_: can resolve for now on frame-sizind and keywords, and file issue for default sizing<br>
&lt;bramus> astearns: Is that OK with you koji and oriol? to not add length for now and file new issue for it<br>
&lt;bramus> PROPOPSED RESOLUTION: Define frame-sizing with various height and with keywords, with default of auto<br>
&lt;bramus> RESOLVED: Define frame-sizing with various height and with keywords, with default of auto<br>
&lt;bramus> smfr: this is just about iframe and also object?<br>
&lt;bramus> chrisl: why would object be different?<br>
&lt;bramus> iank_: can take it as an issue<br>
&lt;bramus> fantasai: does svg have different people between iframe and ??<br>
&lt;bramus> dbholbert: it does<br>
&lt;smfr> s/??/object/<br>
&lt;bramus> s/people/behavior<br>
&lt;bramus> iank_: thank you for the discussion, and we’ll file some follow-up issues<br>
&lt;dholbert> specifically if you put an SVG with large height/width/viewBox into an iframe, then we put the iframe at the default object size and we let the SVG overflow and have large scrollWidth and scrollHeight<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1771#issuecomment-3806716273 using your GitHub account


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

Received on Tuesday, 27 January 2026 18:09:41 UTC