Skip to content
HTML·Intermediate·Conceptual·1 min read

What decides which image the browser actually downloads for an img with srcset and sizes?

Short interview answer

The browser combines the srcset candidates, each tagged with a width or pixel-density descriptor, with the sizes value, an estimate of rendered width per media condition, the current viewport width, and the screen's device pixel ratio. It picks a candidate before layout is finalized and before any bytes are downloaded, using sizes as its best guess of rendered width.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Images, media, and responsive assets

Related questions