From b472ec5c6dcc3cc19b8aeb1208a1137ed3c02ddb Mon Sep 17 00:00:00 2001 From: Koji Ishii Date: Wed, 12 Nov 2025 18:49:02 +0900 Subject: [PATCH] [css-sizing-4] Add responsively-sized iframes Based on the resolutions at: https://github.com/w3c/csswg-drafts/issues/1771#issuecomment-989034819 --- css-sizing-4/Overview.bs | 61 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/css-sizing-4/Overview.bs b/css-sizing-4/Overview.bs index d7135b202c3..b07de4a958b 100644 --- a/css-sizing-4/Overview.bs +++ b/css-sizing-4/Overview.bs @@ -530,7 +530,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties
 	Name: contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size
-	Value: auto? [ none | <> ]
+	Value: auto? [ none | <> ] | from-element
 	Initial: none
 	Inherited: no
 	Logical property group: contain-intrinsic-size
@@ -573,6 +573,11 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties
 			
 			content-visibility/content-visibility-058.html
 			
+
+		: from-element
+		:: This value enables the responsively-sized iframes.
+
+			Note: The name needs further discussion.
 	
 
 	If an element has an [=explicit intrinsic inner size=] in an axis,
@@ -656,6 +661,60 @@ Last Remembered Size
 		even across changes such as going to/from ''display: none''.
 	
 
+

+Responsively-sized iframes

+ + Iframes participate in the layout of the parent document, + via the style and layout of their owning <iframe> element. + However, unlike other HTML elements such as <div>, + iframe elements do not have the ability to support responsive layout, + i.e. size themselves automatically + to contain the [=natural size=] dimensions of the contents of the iframe. + Instead, browsers automatically add scrollbars to iframes as necessary, + so that users can access the content. + + Responsive iframes adds responsive layout to iframes, + similar to embedded SVG documents + in <object> and <embed> elements. + + To preserve privacy and security guarantees of cross-origin content, + both the embedding and embedded document must opt in. + The embedding document opts in by applying the ''from-element'' value to + the ''contain-intrinsic-block-size'' property on the <iframe> element. + The embedded document opts in by adding the + <meta name="responsive-embedded-sizing"> tag. + + When the meta tag is present at the time of + the DOMContentLoaded and load events, + the embedding document is notified + with the new [=natural height=] of the embedded document. + If the ''contain-intrinsic-block-size'' + on the box for the <iframe> element is set to ''from-element'', + it takes this height as the [=explicit intrinsic inner size=] of the box. + Subsequent changes to content, styling or layout of the embedded document + do not affect the <iframe> sizing. + +
+ When the embedded document has the following HTML: +
+		<meta name="responsive-embedded-sizing">
+		<div style="height: 500px"></div>
+		
+ and the embedding document has the following CSS: +
+		iframe {
+			contain-intrinsic-block-size: from-element;
+		}
+		
+ The height of the <iframe> will be 500px. +
+ + In addition, + the embedded document can call window.requestResize() + to notify its new [=natural height=] to the embedding document. + If the meta tag is not present at the time of the call, + it throws a NotAllowedError DOMException instead. +

Interaction With ''overflow: auto''