What the explicit width and height warning actually means
The warning is not saying your site is globally slow or that the image is inherently bad. It says the browser does not know the image’s slot size soon enough. Without explicit dimensions, the browser lays out the surrounding content first and then recalculates when the image data arrives. That recalculation is the layout shift.
It helps to separate the effect from the cause. The visible paragraph that moves is only the symptom. Adding width to the text cannot fix a missing image slot. The fix belongs on the image element or its container, because that is where the browser needs stable geometry.
If the image is responsive, the classic pattern is still valid: <img src="..." width="640" height="280" style="max-width:100%;height:auto;">. The width and height attributes communicate the intrinsic aspect ratio, while CSS keeps the image fluid. The browser can then reserve the correct space before the file is painted.
How to trace the shift in Chrome DevTools
Open the Chrome DevTools Performance reference and record a Performance trace. Turn on the Layout shifts track, select the shift entry, and inspect the impacted nodes. Then follow the likely preceding image or ancestor that caused the movement. This gives you the chain, not just the symptom.
That inspection step matters because the moved element is often innocent. A headline, paragraph, or card may jump, but the real problem is the late image above it. If the layout shift starts exactly when the image appears, the browser did not have a reliable slot early enough.
Use the trace together with the DOM. If you see the shift at image paint time, look for missing dimensions, a changed aspect ratio, or a template that strips width and height before output.
Fix images without explicit width and height
The simplest fix is to set width and height in the markup, even when the image is later scaled by CSS. For a 640×280 image, the copyable pattern is:
Which width and height values should a responsive image use?
The source is 640×280, so its ratio is 16:7. A 320 px container should reserve about 140 px of height. Verify at two viewport widths in DevTools. The attributes provide the source ratio while the layout controls the rendered size.
<img src="/img/example.svg" width="640" height="280" alt="Example" style="max-width:100%;height:auto;">
Those attributes do not force a fixed on-screen size. They let the browser infer the ratio up front. The CSS keeps the image responsive. Without the attributes, the browser has to wait, and the paragraph below may jump down when the image finally arrives.
If you need a placeholder, reserve the slot with aspect-ratio on a wrapper. For example:
<div class="media-slot"><img src="/img/example.svg" width="640" height="280" alt="Example"></div>
.media-slot { aspect-ratio: 640 / 280; width: 100%; }
.media-slot > img { width: 100%; height: auto; display: block; }
This is useful when the image sits inside a card, teaser, or article block that must remain steady before the network response arrives.
If you use srcset, keep the same aspect ratio across every candidate in the set. Then the browser can choose a file without changing the reserved height. If you use <picture> for art direction and different crops, test each breakpoint separately, because different crop ratios need different reserved slots.
Here is a worked decision table you can use during debugging.
| symptom | possible cause | how to check | how to fix | evidence the fix worked |
|---|---|---|---|---|
| Text jumps down when the image appears | The <img> tag has no width and height |
Open DevTools, find the Layout shift entry, and inspect the preceding image | Add width and height that match the file’s real aspect ratio | The next paragraph stays at 404.109375 and local shift is 0 |
| A CMS removes the dimensions on save | The template or editor strips attributes | Inspect the final HTML in the browser | Fix the output template or the attribute allowlist | Width and height remain in the DOM and the text no longer moves |
Only some breakpoints shift in a <picture> block |
The crops have different aspect ratios | Check media queries and the actual crop files | Reserve a different slot for each crop and test every breakpoint | Each breakpoint keeps the same pre-load slot height |
| The shift exists, but the image is not the real cause | Another element is changing size | Open impacted nodes and follow the ancestor chain | Reserve space for the actual changing block | The shift entry disappears or drops to 0 |

Worked comparison with the recorded measurements
The local fixture used three runs per variant, the same 780×820 viewport, and the same delayed 640×280 SVG. The table below shows the medians. This is a synthetic single-shift fixture, not field CLS.
| variant | median beforeY | median afterY | median deltaY | median local shift |
|---|---|---|---|---|
| missing-dimensions | 124.109375 | 404.109375 | 280 | 0.0377 |
| reserved-space | 404.109375 | 404.109375 | 0 | 0 |
The practical meaning is simple. Without a reserved slot, the paragraph drops 280 CSS pixels when the image appears. With explicit dimensions, the same paragraph stays put. That is the whole point of the warning: the browser can only stabilize layout if it knows the image geometry early enough.
A one-page workflow you can repeat
Start with a Performance recording in Chrome DevTools. Find the Layout shift entry, open impacted nodes, and identify the image or ancestor that appears just before the movement. Then update the markup so the slot is known in advance, and record again.
If you already have a version with width and height and another one without them, compare the two under the same viewport. In this fixture, the difference is direct: one variant produces a 280 CSS pixel move and a local shift of 0.0377, the other produces zero shift.
Checklist before you publish
- Every meaningful
<img>has width and height that match the real aspect ratio. - Responsiveness comes from
max-width:100%;height:auto;, not from removing dimensions. - Every
<picture>breakpoint is tested with its own crop ratio. - Your CMS does not strip width and height at save time.
- You have traced at least one Layout shift in Chrome DevTools and checked the preceding image or ancestor.
- If an image arrives late, the wrapper reserves space with
aspect-ratioor equivalent markup.
Separate layout shifts from other performance problems
If the main image is slow to appear, inspect LCP image request discovery. If the interface responds slowly after a click, trace the interaction for INP. Keep test conditions fixed when you compare Lighthouse reports across releases.
Quick Q&A
Why isn’t the moved paragraph the real problem?
Because it is usually reacting to a late change above it. The real fix is to stabilize the image slot, not the text below.
Can CSS alone solve this?
Yes, if CSS reserves the slot with aspect-ratio. But the browser still needs the real ratio from the image or its wrapper.
Do I still need width and height for responsive images?
Yes. They provide the intrinsic ratio, and CSS handles the responsive scaling.
Will adding width to nearby text help?
No. The page shifts because the image space was unknown, not because the paragraph was too narrow.
What if the image crop changes across breakpoints?
Test each breakpoint separately and reserve different slots where the ratio changes.
For related background reading, the official web.dev articles Optimize CLS and CLS explain why explicit dimensions matter and how layout stability is measured. If you want adjacent performance topics, the supplied Chrome and web.dev references above are the right place to continue.
Need help with your website?
Development and SEO services →