Skip to main content
HTML Validation

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

About This HTML Issue

The width and height attributes on <img> elements expect a digit to specify the dimension in pixels. It should not contain units, letters or percent signs.

You can achieve this using CSS instead, for example:

<!-- Invalid syntax, the height attribute expects only digits -->

<img src="photo.jpg" alt="cat" height="auto" />

<!-- Valid syntax using CSS -->

<img src="photo.jpg" alt="cat" style="height: auto"  />

Learn more:

Last reviewed: October 27, 2022

Was this guide helpful?

Find issues like this automatically

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

Ready to validate your sites?
Start your free trial today.