Skip to main content
HTML Validation

Bad value X for attribute “srcset” on element “img”: Must contain one or more image candidate strings.

About This HTML Issue

The srcset property on img elements, when used, requires at least one value. This property is a string which identifies one or more image candidate strings, separated using commas (,) each specifying image resources to use under given circumstances.

Each image candidate string contains an image URL and an optional width or pixel density descriptor that indicates the conditions under which that candidate should be used instead of the image specified by the src property.

Example:

<img
    src="/img/cat-200px.png"
    alt="Cat"
    srcset="
      /img/cat-200px.png 1x,
      /img/cat-400px.png 2x
    ">

Last reviewed: November 30, 2022

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.