Skip to main content
HTML Validation

Bad value X for attribute “srcset” on element “img”: Expected width descriptor but found Y at Z. (When the “sizes” attribute is present, all image candidate strings must specify a width.)

About This HTML Issue

All values in the srcset attribute must include a width descriptor (such as 300w) when the sizes attribute is present.

The srcset attribute is used to provide multiple image sources for responsive images. Each image candidate string in srcset must specify the image’s width (e.g., 600w) or pixel density (e.g., 2x). When you use a sizes attribute, all srcset candidates must use width descriptors (w).

Example of incorrect usage:

<img
  src="/img/pic1.jpg"
  srcset="/img/pic1.jpg"
  sizes="(max-width: 600px) 100vw, 600px"
  alt=""
>

This example is invalid because the srcset value does not include a width descriptor.

Corrected usage with width descriptors:

<img
  src="/img/pic1.jpg"
  srcset="/img/pic1.jpg 600w"
  sizes="(max-width: 600px) 100vw, 600px"
  alt=""
>

If you have multiple image sizes, include each with its corresponding width:

<img
  src="/img/pic1.jpg"
  srcset="
    /img/pic1_small.jpg 300w,
    /img/pic1.jpg 600w
  "
  sizes="(max-width: 600px) 100vw, 600px"
  alt=""
>

Always match each image URL in srcset with a width (w) or pixel density (x) descriptor if appropriate for your layout.

Last reviewed: July 22, 2025

Was this guide helpful?

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Ready to validate your sites?
Start your free trial today.