# Bad value X for attribute “sizes” on element “img”: Bad CSS number token: Expected a minus sign or a digit but saw “"” instead at Y.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-sizes-on-element-img-bad-css-number-token-expected-a-minus-sign-or-a-digit-but-saw-quote-instead-at-y
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The value of the `sizes` attribute on an `<img>` starts with a literal `"` character, which can't begin a media condition or a CSS length.

`sizes` holds a comma-separated list of source sizes. Each one is an optional media condition followed by a length, as in `(max-width: 600px) 100vw`, and the last one is usually a plain length such as `600px`. Lazy-loaded images can also start the list with `auto`. The quotes around an attribute value are HTML syntax, not part of the value. When an extra `"` ends up inside it, the validator tries to read the entry as a length, finds the quote where it expects a digit or a minus sign, and rejects the value.

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 `sizes=&quot;(max-width:` as an unquoted value that stops at the first space. The rest of the list turns into stray attributes such as `600px)` and `100vw,`, which the validator reports separately, and the bad value in this message is only the first word, such as `"(max-width:` or `"auto,`. In the second, the value is wrapped in two sets of quotes, as in `sizes='"100vw"'`, and the whole list is the bad value.

Browsers drop a `sizes` value they can't parse and fall back to `100vw`. They then pick the `srcset` candidate meant for a full-width layout, which is often a larger file than the image slot needs.

The cause rarely affects `sizes` alone. If `width`, `height` or `srcset` 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="logo-600.png 600w, logo-1200.png 1200w"
  sizes=&quot;(max-width: 600px) 100vw, 600px&quot;>
```

## 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">
```
