All cases
RL-007 / Overflow & ReflowEvidence verified

Make Fixed-Size Iframes Fit Narrow Containers

A 640 by 360 iframe preserves its authored desktop dimensions inside a narrower article, producing page-level overflow instead of scaling as a bounded 16:9 region.

Experiment mode

Fixture viewport

Failingwidth: 640px
Viewport / page
--
Iframe
--
Page overflow
--
Fixedinline-size: 100%
Viewport / page
--
Iframe
--
Page overflow
--

Three-browser evidence verified. Live values come from your current browser. The formal matrix records the controlled browser runs and fixture revision used for the published conclusion.

Observed failure

The embedded frame is wider than the article

The iframe has explicit 640 by 360 CSS dimensions. At narrow viewports its rendered inline size remains 640 pixels, so the replaced element extends beyond the article and increases the document scroll width.

Minimal code diff

Bound the frame and declare its ratio

Let the iframe use the available inline size, cap it at its container, and declare `aspect-ratio: 16 / 9` so its block size follows without distortion.

Before

.demo-frame {
  width: 640px;
  height: 360px;
}

After

.demo-frame {
  inline-size: 100%;
  max-inline-size: 640px;
  block-size: auto;
  aspect-ratio: 16 / 9;
}

Root cause

An iframe is a replaced element whose outer box is sized by the embedding page. Its nested document does not make a fixed 640-pixel outer width responsive. When that authored width is larger than the containing block, the iframe itself contributes to page-level horizontal overflow.

The nested document and the outer iframe are separate sizing contexts. The outer page must constrain the iframe box. A preferred aspect ratio then relates its responsive inline size to its block size.

Inspect both sides of the embed boundary

First measure the outer iframe rectangle from the host page. If its right edge crosses the article boundary, fix the host sizing before debugging the nested document. Then inspect the embedded experience at the resulting narrow size: its own controls, text, focus order, and internal scrolling can still fail even when the outer 16:9 box fits perfectly.

Record who owns each layer. The host page controls the iframe dimensions, accessible title, loading strategy, sandbox, and allow permissions. The embedded provider controls its internal responsive behavior and data processing. The project fixture keeps both layers local so its geometry result is reproducible, but a production review must test the actual provider and disclose its privacy behavior.

When this fix is not enough

Responsive dimensions do not make the embedded document accessible, secure, or fast. Production embeds still need an accurate title, appropriate sandbox and permissions policies, a loading strategy, and a provider whose own content works at the resulting size. Some embeds need a wrapper when supporting older layout code or a maximum width smaller than the article.

Regression condition

At 320 and 375 CSS pixels, the failing iframe must create positive page-level overflow. The fixed iframe must remain inside the page, render no wider than 640 pixels, and preserve a 16:9 rendered ratio in every recorded browser.

Primary references

Sources checked for this case

  1. HTML Standard - the iframe element - WHATWG, checked 2026-08-04
  2. CSS Box Sizing Module Level 4 - preferred aspect ratios - W3C, checked 2026-08-04
  3. Understanding Success Criterion 1.4.10: Reflow - W3C Web Accessibility Initiative, checked 2026-08-04

Formal evidence

Browser and viewport matrix

Three-browser run

Cells show failing / fixed page overflow in CSS pixels.

Browser32037576810241440
Chromium+360 / +0+305 / +0+0 / +0+0 / +0+0 / +0
Firefox+360 / +0+305 / +0+0 / +0+0 / +0+0 / +0
WebKit+360 / +0+305 / +0+0 / +0+0 / +0+0 / +0
18/18 recorded assertions passed
  • chromium-failing-overflow-320360px
  • chromium-fixed-overflow-3200px
  • chromium-fixed-frame-ratio-320240x135 rendered
  • chromium-failing-overflow-375305px
  • chromium-fixed-overflow-3750px
  • chromium-fixed-frame-ratio-375295x166 rendered
  • firefox-failing-overflow-320360px
  • firefox-fixed-overflow-3200px
  • firefox-fixed-frame-ratio-320240x135 rendered
  • firefox-failing-overflow-375305px
  • firefox-fixed-overflow-3750px
  • firefox-fixed-frame-ratio-375295x166 rendered
  • webkit-failing-overflow-320360px
  • webkit-fixed-overflow-3200px
  • webkit-fixed-frame-ratio-320240x135 rendered
  • webkit-failing-overflow-375305px
  • webkit-fixed-overflow-3750px
  • webkit-fixed-frame-ratio-375295x166 rendered