About This HTML Issue
The sizes attribute on an img element contains a value that is missing a CSS unit (such as px, vw, or em).
The sizes attribute tells the browser how wide an image will be displayed at a given viewport condition. Each entry in the sizes list must be a valid CSS length. A bare number like 300 is not a valid CSS length — it must include a unit, such as 300px or 50vw.
A common mistake is writing something like sizes="(max-width: 600px) 300, 600" instead of sizes="(max-width: 600px) 300px, 600px". Another frequent error is omitting the unit on the default (last) value.
The sizes attribute accepts a comma-separated list of source size entries. Each entry except the last consists of a media condition followed by a length. The last entry is just a length and acts as the default. Every length value must have a CSS unit.
Invalid example
<img
src="photo.jpg"
srcset="photo-300.jpg 300w, photo-600.jpg 600w"
sizes="(max-width: 600px) 300, 600"
alt="A photo">
Both 300 and 600 lack units, so the validator rejects them.
Valid example
<img
src="photo.jpg"
srcset="photo-300.jpg 300w, photo-600.jpg 600w"
sizes="(max-width: 600px) 300px, 600px"
alt="A photo">
You can also use viewport-relative units like vw:
<img
src="photo.jpg"
srcset="photo-300.jpg 300w, photo-600.jpg 600w"
sizes="(max-width: 600px) 100vw, 50vw"
alt="A photo">
Check every length in your sizes attribute and make sure each one ends with a valid CSS unit. The calc() function is also allowed, for example calc(100vw - 2rem).
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.