Skip to main content

HTML Guide

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

The sizes attribute specifies the size of the image when it is displayed on different devices.

The error message is saying that the value auto is not a valid value for the sizes attribute.

To fix this issue, you need to replace the value auto with a valid size. You can use a width descriptor or a media query to specify the size for different device widths.

Here’s an example of using a width descriptor:

<img src="example.jpg" sizes="(max-width: 600px) 100vw, 50vw" />

This example sets the size of the image to 100% of the viewport width when the device width is less than or equal to 600px, and 50% of the viewport width for larger device widths.

Alternatively, you can remove the sizes attribute altogether and let the browser decide the best size for the image based on the viewport size.

<img src="example.jpg" />

If you do this, the browser will use the default sizes value of 100vw and will scale the image accordingly.

Learn more:

Related W3C validator issues