Skip to content

Technical review: Document responsive iframe sizing#44598

Open
chrisdavidmills wants to merge 1 commit into
mdn:mainfrom
chrisdavidmills:responsive-iframe-sizing
Open

Technical review: Document responsive iframe sizing#44598
chrisdavidmills wants to merge 1 commit into
mdn:mainfrom
chrisdavidmills:responsive-iframe-sizing

Conversation

@chrisdavidmills

Copy link
Copy Markdown
Contributor

Description

Chrome 149 adds support for responsive iframe sizing; see https://chromestatus.com/feature/5108373464547328 (it says 151, but the feature still seems to be behind a pref, since 149).

This relies on three new features:

This PR adds docs for all three features.

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested review from a team as code owners June 29, 2026 13:11
@chrisdavidmills chrisdavidmills requested review from estelle and hamishwillee and removed request for a team June 29, 2026 13:11
@github-actions github-actions Bot added Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs labels Jun 29, 2026
@chrisdavidmills chrisdavidmills changed the title Document responsive iframe sizing Technical review: Document responsive iframe sizing Jun 29, 2026
@github-actions github-actions Bot added the size/m [PR only] 51-500 LoC changed label Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Preview URLs (6 pages)

Flaws (3)

Note! 4 documents with no flaws that don't need to be listed. 🎉

Found an unexpected or unresolvable flaw? Please report it here.

URL: /en-US/docs/Web/API/Window
Title: Window
Flaw count: 2

  • macros:
    • Macro domxref produces link /en-US/docs/Web/API/HTMLElement/invalid_event which is a redirect
    • Macro domxref produces link /en-US/docs/Web/API/Element/select_event which is a redirect

URL: /en-US/docs/Web/API/Window/requestResize
Title: Window: requestResize() method
Flaw count: 1

  • macros:
    • Macro domxref produces link /en-US/docs/Web/API/frame-sizing which doesn't resolve
External URLs (2)

URL: /en-US/docs/Web/API/Window/requestResize
Title: Window: requestResize() method


URL: /en-US/docs/Web/CSS/Reference/Properties/frame-sizing
Title: frame-sizing CSS property


To enable responsive sizing of {{htmlelement("iframe")}} elements based on their content, the [`<meta name="responsive-embedded-sizing">`](/en-US/docs/Web/HTML/Reference/Elements/meta/name/responsive-embedded-sizing) tag can be included in an embedded document to opt it in to sharing its size information with the parent page. The {{cssxref("frame-sizing")}} CSS property can then be set on the `<iframe>` to cause it to adopt the same horizontal or vertical size as the embedded content's actual content size (termed the **internal layout intrinsic size** in the spec). This is useful for avoiding scrollbars on embedded content so that it fits more seamlessly with its embedder.

To resize the `<iframe>` dynamically as the embedded content changes size, you can call the {{domxref("Window.requestResize()")}} method from the embedded page to make it report an updated size, typically from within the event handler that caused the content to change size. If the `<iframe>` is sized using `frame-sizing`, it will then update its size automatically so that it still neatly contains the embeded content.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about mentioning that the size is updated on DOMContentLoad and Load events automatically, and this method provides additional timing? Is this redundant?

To enable responsive sizing of {{htmlelement("iframe")}} elements based on their content, the [`<meta name="responsive-embedded-sizing">`](/en-US/docs/Web/HTML/Reference/Elements/meta/name/responsive-embedded-sizing) tag can be included in an embedded document to opt it in to sharing its size information with the parent page. The {{cssxref("frame-sizing")}} CSS property can then be set on the `<iframe>` to cause it to adopt the same horizontal or vertical size as the embedded content's actual content size (termed the **internal layout intrinsic size** in the spec). This is useful for avoiding scrollbars on embedded content so that it fits more seamlessly with its embedder.

To resize the `<iframe>` dynamically as the embedded content changes size, you can call the {{domxref("Window.requestResize()")}} method from the embedded page to make it report an updated size, typically from within the event handler that caused the content to change size. If the `<iframe>` is sized using `frame-sizing`, it will then update its size automatically so that it still neatly contains the embeded content.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about also describing it'd raise an error if the child didn't opt-in? Is this too much details?

Please see the CSS spec for requestResize for the details of the errors.

Maybe also nice to mention that, if the parent doesn't opt-in (by the frame-sizing property), it doesn't cause an error, but the iframe will not be resized?


{{APIRef}}

The **`requestResize()`** method of the {{domxref("Window")}} interface updates the size information shared by an embedded document with its embedding parent, but only if the embedded page has opted in to sharing its size information.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it sometimes say "embedded document", "embedded page", or "embedded content". Are they intentionally differentiated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants