Stop Fixed-Size Images From Breaking Mobile Layouts
A 640-pixel image keeps its authored width inside a narrower article, forcing the document wider even though its intrinsic aspect ratio is valid.
width: 640px- Viewport / page
- --
- Image
- --
- Page overflow
- --
max-inline-size: 100%- Viewport / page
- --
- Image
- --
- 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 authored image width is larger than its container
The image has a valid 640 by 360 intrinsic size and an explicit 640-pixel rendered width. On a narrow viewport, that width exceeds the article content box and increases the document scroll width.
Minimal code diff
Cap the image at its containing block
Keep the intended width as an upper target, add `max-inline-size: 100%`, and let the block size remain automatic so the intrinsic ratio is preserved.
Before
.article-image {
width: 640px;
height: auto;
}After
.article-image {
width: 640px;
max-inline-size: 100%;
block-size: auto;
}Root cause
An image is a replaced element with intrinsic dimensions supplied by its resource. An authored fixed width can override the normal available inline size. When that width is larger than the containing block, the image itself becomes wider than the article and the page gains horizontal overflow.
The width and height attributes in the fixture communicate the intrinsic ratio before the resource loads. CSS then limits the rendered inline size while preserving automatic proportional height.
Separate intrinsic size from rendered size
Inspect naturalWidth and naturalHeight alongside the rendered rectangle and the containing block’s client width. In this fixture the 640 by 360 intrinsic dimensions are valid; the failure is that the rendered inline size is also forced to 640 pixels inside a narrower article. The fixed state keeps the intrinsic ratio metadata but caps the rendered box at the available boundary.
Test the widest real asset, a slow load, and a failed load state. Width and height attributes should reserve the correct ratio before decoding, while responsive CSS prevents overflow after decoding. Alternative text must still describe the image’s purpose, and any linked or actionable image must retain a visible focus indicator at the reduced size.
When this fix is not enough
Containment does not choose an efficient file for the device. Large production images may also need srcset, sizes, modern formats, compression, and an appropriate loading strategy. Those performance decisions are separate from ensuring the rendered box cannot exceed its content boundary.
Regression condition
At 320 and 375 CSS pixels, the failing image must create positive page-level overflow. The fixed image must remain inside the page, render narrower than its 640-pixel intrinsic width, and preserve the original 16:9 aspect ratio.
Primary references
Sources checked for this case
- HTML Standard - the img element - WHATWG, checked 2026-08-04
- Understanding Success Criterion 1.4.10: Reflow - W3C Web Accessibility Initiative, checked 2026-08-04
Formal evidence
Browser and viewport matrix
Cells show failing / fixed page overflow in CSS pixels.
| Browser | 320 | 375 | 768 | 1024 | 1440 |
|---|---|---|---|---|---|
| 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-320360pxchromium-fixed-overflow-3200pxchromium-fixed-image-ratio-320640x360 intrinsic, 240x135 renderedchromium-failing-overflow-375305pxchromium-fixed-overflow-3750pxchromium-fixed-image-ratio-375640x360 intrinsic, 295x166 renderedfirefox-failing-overflow-320360pxfirefox-fixed-overflow-3200pxfirefox-fixed-image-ratio-320640x360 intrinsic, 240x135 renderedfirefox-failing-overflow-375305pxfirefox-fixed-overflow-3750pxfirefox-fixed-image-ratio-375640x360 intrinsic, 295x166 renderedwebkit-failing-overflow-320360pxwebkit-fixed-overflow-3200pxwebkit-fixed-image-ratio-320640x360 intrinsic, 240x135 renderedwebkit-failing-overflow-375305pxwebkit-fixed-overflow-3750pxwebkit-fixed-image-ratio-375640x360 intrinsic, 295x166 rendered
Run 2026-08-04T11-36-57-234Z. chromium 149.0.7827.201, firefox 153.0, webkit 26.5. Open raw manifest