Info srcset with width descriptors missing sizes
Why an <img srcset> using width descriptors needs a sizes attribute too, and what the browser picks without one.
The validator flags an <img srcset> whose candidates use width descriptors (e.g. 800w) but have no sizes attribute alongside it.
Example
<!-- Wrong: browser has to guess the display size -->
<img src="photo-400w.jpg"
srcset="photo-400w.jpg 400w, photo-800w.jpg 800w, photo-1600w.jpg 1600w"
alt="Product photo">
<!-- Right -->
<img src="photo-400w.jpg"
srcset="photo-400w.jpg 400w, photo-800w.jpg 800w, photo-1600w.jpg 1600w"
sizes="(min-width: 768px) 50vw, 100vw"
alt="Product photo">Why it matters
Width descriptors (400w) tell the browser how large each candidate image file actually is, but not how large the image will be displayed — that's what sizes provides. Without it, the spec says the browser must assume the image displays as wide as the entire viewport, which usually means it picks a needlessly large file on any layout where the image is actually smaller than full-width (a thumbnail, a grid item, a sidebar image). The two attributes work together: srcset lists what's available, sizes says how big it'll actually render, and the browser combines both with the device's pixel density to pick the best file.
Frequently asked questions
Do I need sizes if I only use density descriptors (1x, 2x)?
No — sizes is only relevant to width descriptors (400w). Density descriptors already tell the browser exactly which file to pick for the device's pixel ratio, since the display size is assumed to be the image's natural CSS size in that case.
What's a reasonable sizes value if I'm not sure?
100vw (full viewport width) is a safe default if the image is ever displayed at full width on some breakpoint — it errs toward the browser picking a larger file than strictly necessary rather than a blurry one.