Skip to main content
HTML Validation

Bad value X for attribute “srcset” on element “img”: Bad image-candidate URL: Y: Illegal character in path segment. “"” is not allowed.

About This HTML Issue

The first image URL in the srcset attribute starts with a literal " character, which is not allowed in a URL path.

srcset holds a comma-separated list of image candidates. Each one is a URL, optionally followed by a width descriptor such as 600w or a pixel density descriptor such as 2x. The quotes around an attribute value are HTML syntax, not part of the value. When an extra " ends up inside the value, it becomes the first character of the first URL. A raw " is not allowed in a URL path segment, so the validator rejects that candidate. Browsers read "https://example.com/logo.png as a relative path, because a URL scheme has to start with a letter, and request a file on your own site that does not exist.

The stray quote usually comes from one of two mistakes. In the first, the quotes around the value were HTML-encoded as ", often by a plugin or template that escaped markup a second time. " can't delimit an attribute, so the parser reads srcset="logo-600.png as an unquoted value that stops at the first space. The rest of the list turns into stray attributes such as 600w,, which the validator reports separately, and the bad value in this message is only the first URL. In the second, the value is wrapped in two sets of quotes, as in srcset='"logo-600.png 600w"', and the whole list is the bad value.

The cause rarely affects srcset alone. If width, height, sizes or decoding on the same <img> also report a stray ", fix the code that writes the tag instead of editing each attribute.

Invalid example

<img
src="logo-600.png"
alt="Company logo"
srcset=&quot;logo-600.png 600w, logo-1200.png 1200w&quot;
sizes="(max-width: 600px) 100vw, 600px">

Valid example

<img
src="logo-600.png"
alt="Company logo"
srcset="logo-600.png 600w, logo-1200.png 1200w"
sizes="(max-width: 600px) 100vw, 600px">

Find issues like this automatically

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

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries