๐Ÿ“ฑ HTML

Responsive Images with srcset โ€” Stop Shipping 2MB Photos to Phones

๐Ÿ“… Jul 3, 2026 โฑ 3 min read

A 1600px hero photo on a 375px phone wastes ~80% of the bytes. srcset lets the browser pick the right size.

Width-based srcset (the common case)

<img src="hero-800.jpg"
     srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1600.jpg 1600w"
     sizes="(max-width: 600px) 100vw, 800px"
     alt="Campus" loading="lazy" width="800" height="450">

Reading it: "I have 400/800/1600px versions; on small screens I display full-width, otherwise 800px โ€” browser, do the math (including retina 2x) and fetch the best one."

picture = art direction (different crops)

<picture>
  <source media="(max-width: 600px)" srcset="portrait-crop.jpg">
  <img src="wide-crop.jpg" alt="...">
</picture>

srcset = same image, different sizes. picture = different images per context. That one line is the interview answer.

โ† All Articles