What Are Unsized Images? Complete Guide (2026)
What Are Unsized Images?
Unsized images are <img> and <video> elements that don't declare an explicit width and height (or an equivalent CSS aspect-ratio). Without those values the browser cannot reserve space for the media before it downloads — so when the file finally arrives, every element below it is pushed down. That sudden push is the single largest cause of bad Cumulative Layout Shift (CLS).
Key Facts (TL;DR)
- The fix is two attributes: add
widthandheightto every<img>and<video>tag — even when CSS resizes them. - Impact on CLS: a single unsized hero image can produce a layout shift score of 0.2 – 0.5 on its own — well above Google's "good" ceiling of ≤ 0.1.
- CLS is a confirmed Google ranking signal via the Page Experience update (June 2021), and unsized media is the most common reason pages fail it.
- Modern alternative: CSS
aspect-ratioreserves space proportionally for fluid responsive images. - Browser support: the
width/heightaspect-ratio behaviour has been universal in evergreen browsers since 2019 — there is no compatibility cost to adding them. - Universally fixable: every CMS, framework, and static site generator can emit width/height — the issue is almost always a regression, not a structural limitation.
Think of it like setting a place at a dinner table before the guest arrives. Once you reserve the chair, no one else is shoved sideways when they sit down. width and height are the reservation — the browser knows exactly how much room each image needs, even before a single pixel has loaded.
Why Unsized Images Hurt Your Site
Unsized media damages user experience and rankings in five concrete ways:
- Bad CLS scores:CLS is one of Google's three Core Web Vitals (alongside LCP and INP). Unsized images are the most frequent reason pages fail the 0.1 threshold.
- Misclicks on mobile: a button that gets shoved down half a second after a visitor reaches for it sends them to the wrong destination — including unintended purchases and form submissions.
- Lost reading flow: when a paragraph someone is reading suddenly jumps because a late-loading image arrived above it, many readers do not scroll back.
- Search ranking pressure: CLS feeds the Page Experience signal. Pages that fail Core Web Vitals lose ranking ground in competitive queries where quality is otherwise equal.
- Reduced AI search visibility: generative answer engines and Google AI Overviews preferentially surface pages that already rank well — and unsized-image CLS pulls those rankings down.
How a Missing width/height Triggers Layout Shift
When the browser parses an <img>tag without explicit dimensions, it reserves a content box of effectively zero height. Surrounding elements collapse upward to fill that empty space. Then, when the image file finally downloads and decodes, the browser inserts the real dimensions — pushing every element below the image down by the image's full height.
With width and height attributes (or aspect-ratio CSS), the browser computes an intrinsic aspect ratio at parse time and reserves a correctly-sized box before any pixel downloads. The image fades into a space that already exists.
<!-- Bad: no dimensions, browser reserves 0 height -->
<img src="/hero.jpg" alt="Hero">
<!-- Good: dimensions declared, browser reserves a 16:9 box -->
<img src="/hero.jpg" alt="Hero" width="1600" height="900">
<!-- Even when CSS resizes it, the aspect ratio is preserved -->
<style>
img { width: 100%; height: auto; }
</style>The Common Myth: "Responsive Images Can't Have Dimensions"
False. Since 2019, every evergreen browser uses the width and height attributes only to compute an aspect ratio when CSS overrides the rendered size. With height: auto in your stylesheet, the image still resizes fluidly — the attributes only tell the browser how much space to reserve in advance. Always include them.
How to Detect Unsized Images on Your Site
Audit tooling flags any image-shaped element that lacks explicit dimensions. The most reliable ways to surface them:
- Greadme deep scan — flags every unsized image on a page, names the offending element, and pairs each finding with a one-click GitHub PR that adds the attributes for you.
- Greadme crawler scan — runs the same check across every indexable page on your site, so you can see which templates (product pages, article pages, listing pages) systematically ship unsized media.
- Greadme AI visibility analyzer — connects unsized-image findings to AI-search outcomes by scoring how well each page is positioned to be cited by generative engines.
- web.dev Measure— runs a lab audit and lists offending elements under "Image elements do not have explicit width and height."
- Google Search Console → Core Web Vitals report — surfaces pages that fail CLS in real-user data; unsized images are the most common root cause.
- Chrome DevTools → Performance panel— record a load and use the "Experience" lane to highlight every layout shift event with its causing element.
8 Proven Ways to Fix Unsized Images
1. Add width and height to Every <img>
The most direct fix. Use the image's intrinsic pixel dimensions — they are used only for ratio calculation, not final render size.
<img src="/post-cover.jpg" alt="" width="1200" height="630">2. Use CSS aspect-ratio for Fully Fluid Images
For art-directed responsive images that change shape across breakpoints, set aspect-ratio on the image or its container. The browser reserves the proportional space regardless of viewport width.
img.cover {
aspect-ratio: 16 / 9;
width: 100%;
height: auto;
}3. Set Dimensions on <video> Elements Too
The audit covers any media element. Videos benefit from the same attributes — and the same browser support story.
<video src="/promo.mp4" width="1280" height="720" controls></video>4. Wrap Background Images in a Sized Container
CSS background-image doesn't carry intrinsic dimensions. Reserve space with explicit height, padding-aspect-ratio, or the aspect-ratio property on the wrapping element.
5. Use a Framework Image Component
Next.js <Image>, Nuxt <NuxtImg>, Astro <Image>, and similar components require width and height (or a fill mode that reserves space) by design. Switching to them eliminates an entire class of regression.
6. Set Defaults in Your CMS
Most CMSs store image dimensions when uploaded but only emit them in the rendered HTML if the theme template references them. Audit your image partial / template and ensure both attributes ship.
7. Lint for Missing Dimensions in CI
Add an ESLint rule (e.g., jsx-a11y-style image checks or a custom rule) so missing width/height fails the build. This prevents the regression that initially caused the audit failure.
8. Don't Override Dimensions With Conflicting CSS
If you set width: 100% without height: auto, the browser still uses the attributes for ratio — but a hard height: 100px rule will override it and re-introduce shifts. Pair fluid widths with auto heights.
/* Good — preserves the declared aspect ratio */
img { width: 100%; height: auto; }
/* Bad — forces a fixed height that may not match the file */
img { width: 100%; height: 200px; }Common Unsized-Image Problems and Fixes
Problem: User-Uploaded Content Has No Dimensions
What's happening: Editors paste images from external sources without specifying size, and the CMS rich-text field stores the bare <img>.
Fix: Run a server-side post-processing step that reads each image's intrinsic dimensions and injects width/height before the HTML reaches the browser. Most static-site generators expose a hook for this.
Problem: Images Rendered by JavaScript After First Paint
What's happening: A carousel, lightbox, or related-posts widget injects <img> elements at runtime without dimensions, causing shifts after the document has already rendered.
Fix: Ensure the JS template includes width and height on every injected image, or wrap injection points in a container with a fixed aspect-ratio.
Problem: srcset / picture Elements Without Dimensions
What's happening: Developers add srcset or <picture> for responsive images and assume they replace width/height. They don't — the attributes still belong on the fallback <img>.
Fix: Always set width and height on the <img> inside <picture>. The browser uses those values for ratio regardless of which source wins.
Problem: Lazy-Loaded Images Below the Fold Still Cause Shifts
What's happening: Even with loading="lazy", an image without dimensions reserves zero space. When the user scrolls and it loads, content below it shifts inside the active session window.
Fix: Lazy-loading does not replace dimensions — keep both. loading="lazy" defers the download; width/height reserves the space.
How Different Sizing Strategies Compare
Several techniques reserve space for media. The right one depends on whether the image needs to be fluid, fixed, or art-directed.
| Technique | Best For | CLS Risk | Notes |
|---|---|---|---|
width + height attributes | Almost every image | None when paired with height: auto | The default fix recommended by web.dev. |
CSS aspect-ratio | Fluid images that change ratio across breakpoints | None | Pair with width: 100%; works on containers too. |
| Padding-bottom hack | Legacy support before aspect-ratio shipped | None | Still works; aspect-ratio is cleaner in modern code. |
| No dimensions | Never recommended | High — common cause of CLS > 0.25 | Browser reserves zero space until image arrives. |
Fixed pixel width + height in CSS | Icons, small UI sprites | None | Fine when the image will never resize fluidly. |
FAQ
What does "image elements do not have explicit width and height" mean?
It means at least one <img> or <video> tag on the page is missing both the width and height attributes (and has no equivalent aspect-ratio CSS). Audits flag this because the browser cannot reserve space for the element before it loads, which causes layout shift.
Do I still need width and height if I use CSS to resize the image?
Yes. Modern browsers use the attributes only for the aspect-ratio calculation when CSS overrides the rendered size. Add the intrinsic pixel dimensions to the HTML and use width: 100%; height: auto in CSS — the image will scale fluidly and the space will still be reserved.
Will adding width and height attributes break my responsive layout?
No. Provided your CSS includes height: auto (or equivalent), the rendered size is determined by CSS while the attributes are used purely to reserve space. Browser support has been universal since 2019.
What about background-image in CSS?
CSS background images don't affect layout, but the element they live on still needs reserved space. Set an explicit height, padding-bottom ratio, or aspect-ratioon the container so it doesn't collapse before the background loads.
Is <picture> with srcset enough on its own?
No. <picture> and srcset select which file to load — they don't reserve space. Keep width and height on the inner <img> tag. The browser uses them for the ratio regardless of which source wins.
How do unsized images affect AI search engines like ChatGPT and Perplexity?
Indirectly but meaningfully. AI answer engines and Google AI Overviews tend to cite pages that already rank well in traditional search. Unsized images push CLS above Google's 0.1 threshold, which weakens Page Experience and reduces the odds of the page being chosen as a citation.
Are there any cases where I should not set width and height?
Rarely. The only legitimate exception is when an image's intrinsic dimensions genuinely cannot be known ahead of time (e.g., user-uploaded content rendered with no preprocessing). Even then, the right answer is to add a server-side step that detects the dimensions before the HTML ships — not to leave the image unsized.
Conclusion
Unsized images are the easiest-to-fix performance regression in modern web development. Two attributes, no architectural changes, no CSS overhaul — just width and height on every media element. The payoff is a CLS score that passes Core Web Vitals, fewer misclicks on mobile, and a layout that feels stable from the first paint.
Run a Greadme deep scan to see exactly which images on each page are missing dimensions, then fix them in order of viewport impact.
