Image width and height attributes

Why img tags need width and height attributes to stop the page jumping while images load, how the scan counts missing ones, and how to add them.

What AuditX checks

The scan reads every img tag in your page as the scan saw it, spacer images included. It counts the images that are missing a width attribute, a height attribute or both, and passes when every image has both. When some are missing and the Lighthouse run of this scan completed, the scan uses the Lighthouse list of unsized images to decide: an image without the attributes still counts as sized when CSS gives it a width and a height, or one of them plus an aspect-ratio, and it is left out when it is positioned fixed or absolute, is not displayed, or is an inline SVG, because none of those can make the page jump. It then warns when at least one image is left that is sized neither way (images served by a cookie consent manager such as OneTrust are left out, since it adds those tags, not your site), naming up to three different files (two images of one file both count, but the file is named once), and passes otherwise. The Lighthouse list covers the rendered page, so it also holds images that scripts add after the HTML arrives; its count can be higher than the count of img tags, and it warns even when every img tag in the HTML has both attributes. Without a Lighthouse result it warns when at least one image is missing an attribute, and sizes set in CSS do not count. It gives an info note, which is not counted in the score, when the page has no images. Any attribute value counts. The scan does not check that the numbers match the real size of the image. This check has no not-measured state.

Why it matters

Without width and height, the browser does not know how much room an image needs until it has downloaded it. The text then jumps down when the image appears.

Google measures this jump as Cumulative Layout Shift, which is one of its Core Web Vitals. A page that does not shift is also calmer to read.

How to fix it

  1. Add width and height to each img tag, using the real pixel size of the image file.
  2. Keep the image responsive with CSS: set max-width: 100% and height: auto. The browser then uses the attributes to reserve the right ratio.
  3. In WordPress, images added through the media library usually get both attributes. Check images added by a theme, a slider or custom HTML.
  4. If an image is sized only by CSS, you can instead give it an aspect-ratio in CSS. The scan only counts the attributes, so it will still be listed.
<img src="team.jpg" alt="Our team" width="800" height="600">

img { max-width: 100%; height: auto; }

Does your site pass this check? A free scan runs it with every other check and shows the result in about a minute.

Scan my site

Sources

Related checks

Last reviewed 2026-11-13.