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

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-srcset-on-element-img-bad-image-candidate-url-y-illegal-character-in-path-segment-quote-is-not-allowed
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

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 `&quot;`, often by a plugin or template that escaped markup a second time. `&quot;` can't delimit an attribute, so the parser reads `srcset=&quot;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

```html
<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

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