# Bad value X for attribute “width” on element “img”: Expected a digit but saw “"” instead.

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

A stray double quote ended up inside the `width` value of an `<img>`, usually because the opening quote is missing (`width=200"`) or the quotes don't match (`width='200"'`).

The `width` attribute takes a non-negative integer: digits only, with no quotes, units or spaces. Without an opening quote, the browser reads the value as unquoted, which runs until the next space or `>`, so the closing `"` becomes part of the value. The validator reports this case twice, once with this message and once as `“"” in an unquoted attribute value`. When the value opens with a single quote and closes with a double quote, it runs until the next single quote, and the `"` again lands inside it.

Browsers parse `width` leniently and read `200"` as `200`, so the image often looks fine. A value that starts with the quote, such as `"200"`, fails to parse, and the browser ignores it. The image then gets no reserved space before it loads, and the content below it shifts once it arrives.

Templates and string-built HTML cause most of these, for example `width=<%= width %>"` with the opening quote left out. Put matching double quotes around the number.

## Invalid example

```html
<img src="photo.jpg" alt="A red car" width=200" height="150">
<img src="photo.jpg" alt="A red car" width='200"' height="150">
```

## Valid example

```html
<img src="photo.jpg" alt="A red car" width="200" height="150">
```
