Write srcset & sizes, drag the viewport → your own browser picks the file. See the slot, the densities, your screen's DPR, and which file downloads at three…
Why it matters
Images are usually a page’s heaviest part. A dishonest sizes quietly downloads a file 4× bigger than what shows, and no error tells you. Without width and height, the text below jumps as the photo arrives. Seeing slot → density → DPR turns srcset from a copy-paste spell into a choice you understand.
The key idea
The browser picks the file before its CSS is done
Common mistakes
Writing sizes="100vw" though the image is only 300px wide, and a huge file downloadssizes is evaluated before layout is done, so the browser trusts the number you give. Mirror the real shown width, your layout’s media queries included: (min-width: 700px) 50vw, 100vw.
Using srcset to change the photo’s crop per screen, yet it stays the same photo in another sizesrcset is only for resolution switching (the same photo, other sizes), and the browser is free to choose. For another crop per screen (art direction) use <picture> + <source media>, which must be obeyed.
Forgetting src, and old browsers show no image Old browsers ignore srcset. Without a plain src as the fallback there is no image at all. src is also what is used when every candidate fails.
Try it in this playground
Slide the screen width or change the DPR until the downloaded file changes That is the threshold: the candidate dense enough before now falls short.
Open 300px card, sizes 100vw Step 4 shows a file far bigger than what shows: the browser trusts sizes.
Remove the sizes attribute from the hero image Without sizes, the browser assumes 100vw.
Open <picture> art direction at 375px<source media> must be obeyed: the portrait crop shows on a narrow screen.