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

How does a pixel-density descriptor like 2x differ from a width descriptor like 400w in srcset?

Short interview answer

A density descriptor tells the browser to pick a candidate based purely on device pixel ratio, independent of layout width, which suits fixed-size images like icons or avatars. A width descriptor requires a sizes attribute so the browser can combine rendered width with pixel density, and the two descriptor types cannot be mixed in one srcset.

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