Responsive image attributes

How the scan checks srcset and sizes on images, when mixed descriptors fail and a lone sizes attribute warns, and how to write them correctly.

What AuditX checks

The scan reads the HTML of the page and looks at every img and source element that has a non-empty srcset or sizes attribute. If there are none, the result is an info note, which does not lower the score. For each srcset it reads the list of image addresses and their descriptors, taking care that a comma inside an address is not mistaken for a separator. The check fails when at least one srcset mixes width descriptors (such as 400w) with pixel density descriptors (such as 2x), or has an address without any descriptor next to width descriptors. The message names up to 3 files. The check warns, when nothing fails, if an element has a sizes attribute but no srcset. Two cases are excused: an img inside a picture element whose source elements carry a srcset, and an element with a data-srcset attribute, which lazy-loading scripts use. If neither happens, the check passes. A fail beats a warning, so only the fail is reported when both exist. The scan does not judge descriptors that are neither w nor x, the content of sizes, whether the files exist, or whether the chosen sizes fit the layout. A separate check covers whether a phone really gets a small image. This check counts in the performance score.

Why it matters

MDN states that it is incorrect to mix width descriptors and pixel density descriptors in the same srcset attribute, and that the specification requires sizes only when srcset uses width descriptors.

web.dev explains that serving responsive images saves data by serving smaller images to smaller screens, and can improve Largest Contentful Paint. Markup that does nothing removes that gain.

How to fix it

  1. Inside one srcset, use the same kind of descriptor on every entry: all widths (480w, 960w) or all pixel densities (1x, 2x).
  2. Remove the sizes attribute from any element that has no srcset, or add the srcset it belongs to.
  3. If you want the browser to pick by screen width, use width descriptors together with a sizes value that says how wide the image is shown.
  4. Keep a normal src as a fallback, and check each image in a phone-size window after the change.
<img src="/img/shop-960.jpg" srcset="/img/shop-480.jpg 480w, /img/shop-960.jpg 960w" sizes="(max-width: 600px) 100vw, 600px" width="960" height="640" alt="Our shop front">

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.