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

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

The `height` attribute on an `img` element contains the string `auto"` instead of a valid non-negative integer, likely due to a typo with an extra quote.

The `height` attribute on `img` elements only accepts non-negative integers representing the image's height in CSS pixels. Values like `auto`, percentages, or any non-numeric strings are not valid. The extra trailing quote (`"`) in `auto"` suggests a copy-paste error or a quoting mistake in your markup.

If you want the image height to adjust automatically, simply omit the `height` attribute altogether, or set `height: auto` in CSS instead. It's still recommended to include both `width` and `height` attributes with actual pixel values to help the browser reserve the correct space and prevent layout shifts (CLS).

## Invalid Example

```html
<img src="photo.jpg" alt="A photo" width="600" height="auto">
```

## Fixed Example

Using CSS for automatic height while keeping the HTML attribute for layout stability:

```html
<img src="photo.jpg" alt="A photo" width="600" height="400" style="height: auto;">
```

Or simply omit the `height` attribute if you don't know the intrinsic dimensions:

```html
<img src="photo.jpg" alt="A photo" width="600">
```
