Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Images missing width and height causing layout shift: how to fix

SEO-201Low impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

When a browser reads your HTML, it lays out the page before images have downloaded. If an <img> tag has no width and height, the browser doesn't know how much room to leave. It reserves nothing, then pushes the text and buttons below it down once the image arrives. That jump is called layout shift.

How a missing size shifts the page
  1. HTML loadsBrowser lays out text and button
  2. Image has no size0 px of space reserved
  3. Image arrivesContent is pushed down
  4. Visitor tapsHits the wrong element

The image has no reserved space, so everything below it moves when it loads.

Why it costs you leads or sales

What layout shift can cost you
  • Visitors tap the wrong link or button because it moved just as they touched it.
  • A form or call-to-action jumps away while someone is reading or filling it in.
  • Pages feel unstable, which lowers trust on checkout and lead pages.
  • A poor CLS score is a small negative signal in Google's page experience data.
CLS before and after adding image dimensionsExample numbers
CLS before and after adding image dimensions (example)Before (no dimensions): 0.3 CLS score; After (width and height set): 0 CLS score0010.30Before (no dimensions)After (width and heig…CLS score

Example: illustrative scores for one page. Google rates a CLS of 0.1 or less as good.

How to check if your site has it

Find images without dimensions
  1. Run PageSpeed Insights

    Open pagespeed.web.dev, enter the page URL and look for the audit 'Image elements do not have explicit width and height' and a CLS value in the report.

  2. Use Chrome DevTools

    Open DevTools, go to the Performance panel, record a page load and tick Layout Shifts in the Experience row. Click a shift to see which element moved.

  3. Scan the HTML

    View the page source and search for <img. Any tag without both width= and height= is a candidate.

  4. Test on a slow connection

    In DevTools Network panel, set throttling to Slow 4G and reload. Watch for jumps as images arrive.

How to fix it

Image with reserved spacehtml
<img src="/images/hero.jpg" alt="Team at work" width="1200" height="800">
Keep images responsivecss
img {
  max-width: 100%;
  height: auto;
}

/* For images inside a fixed-ratio box */
.card-media {
  aspect-ratio: 3 / 2;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
Fix by platform
  1. Update WordPress

    WordPress adds width and height to images inserted through the editor automatically. Images in older posts, page builders or hard-coded theme templates may lack them.

  2. Fix theme templates

    Where a template prints an image, use wp_get_attachment_image() or the_post_thumbnail(), which output the dimensions. Avoid hand-written <img> tags without sizes.

  3. Check your page builder

    In your builder's image settings, make sure the image isn't set to output without size. Also check any optimisation plugin settings that strip attributes.

Image markup

Before

  • <img src="hero.jpg"> with no size
  • No space reserved
  • Text jumps when the image loads

After

  • <img src="hero.jpg" width="1200" height="800">
  • Space reserved from first paint
  • Layout stays still

How to confirm it's fixed

Confirmation checks
  • Re-run PageSpeed Insights and confirm the image dimension audit passes.
  • Record a new Performance trace in DevTools and check there are no layout shifts from images.
  • Reload on throttled Slow 4G and confirm nothing jumps.
  • Test on mobile width, where images are scaled the most.
  • Allow time for field data: Search Console's Core Web Vitals report uses real-user data collected over about 28 days.

How to prevent it happening again

Habits that keep it fixed
  • Make width and height a required part of your image component or template.
  • Add the global img { max-width: 100%; height: auto; } rule to your base CSS.
  • Reserve space for banners, embeds, ads and cookie bars with a fixed height or aspect-ratio.
  • Check CLS after installing a new theme, plugin, popup or app.
  • Set a CLS budget and monitor it on your key pages.

How FunnelGuard handles this

Questions people ask

Why does my page jump when images load?

The browser doesn't know the image's size until the file downloads, so it reserves no space. When the image arrives, the content below is pushed down. Adding width and height attributes or a CSS aspect-ratio reserves the space in advance.

Do I need width and height on every image?

Yes, for any image that loads in the page content. The attributes let the browser work out the aspect ratio before the file arrives. Images that are absolutely positioned or sit inside a box with a fixed aspect-ratio are less likely to shift.

Will width and height attributes break responsive images?

No. Set the attributes to the file's real pixel size and add img { max-width: 100%; height: auto; } in CSS. The image then scales to its container while the browser keeps the correct aspect ratio.

What is a good CLS score?

Google rates a Cumulative Layout Shift of 0.1 or less as good, 0.1 to 0.25 as needing improvement, and above 0.25 as poor. It is measured on real visits at the 75th percentile.

How do I find which image causes layout shift?

Open Chrome DevTools, record a trace in the Performance panel and enable Layout Shifts in the Experience row. Clicking a shift shows the moved elements. PageSpeed Insights also flags images without explicit dimensions.

Does CSS aspect-ratio replace width and height?

It can reserve the same space, and it works well for containers, embeds and background boxes. For plain <img> tags, width and height attributes are the simplest fix because browsers use them automatically.

Can FunnelGuard find images missing width and height?

Only partly. FunnelGuard checks a CLS budget on your pages and alerts you if layout shift goes over it. It doesn't list individual images without dimensions, so you still need PageSpeed Insights or DevTools to find them.

Do lazy-loaded images need width and height too?

Yes. Lazy loading delays the download, which makes reserved space more important. Without dimensions, each image that scrolls into view can push the content around it.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: CLS budget via cwv_budget.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.