ImageMay 2026 Β· 7 min read

Responsive Images with srcset and sizes: Complete Guide

Serve the right image size to every device. srcset, sizes, picture element, and art direction for optimal performance.

πŸ“
Try the Aspect Ratio Calculator
Free, no signup
β†’
DG
Derek Giordano
Designer & Developer
In this guide
01Why Responsive Images Matter02Using srcset and sizes03The picture Element04Lazy Loading and Performance
⚑ Key Takeaways
  • Serve the right image size to every device.
  • Why Responsive Images Matter.
  • Using srcset and sizes.
  • The picture Element.
  • Lazy Loading and Performance.

Why Responsive Images Matter

A single image can’t serve every device well. A hero image for a 2560px Retina display is 4x larger than what a 375px phone needs. Without responsive images, mobile users download massive files they can’t benefit from. Responsive images let the browser choose the most appropriate source from candidates. The average web page is over 50% images by weight β€” optimizing them is the single biggest performance lever for most sites.

Using srcset and sizes

The srcset attribute provides image sources at different widths: srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w". The sizes attribute tells the browser how wide the image displays at each viewport: sizes="(max-width: 768px) 100vw, 50vw". The browser picks the smallest image that covers the display at current viewport and pixel density. Use the Aspect Ratio Calculator to determine proper dimensions.

The picture Element

The picture element provides art direction β€” different crops for different screens, not just different resolutions. It’s also used for format negotiation: serve AVIF to supporting browsers, WebP to the rest, JPEG as universal fallback. Combine both uses for maximum optimization β€” different formats AND different crops based on viewport width.

Lazy Loading and Performance

Always include loading="lazy" on images below the fold. Don’t lazy-load your LCP hero image β€” it needs to load immediately. Add fetchpriority="high" to your hero. Always set width and height attributes to prevent CLS. The browser reserves correct space before the image loads, eliminating the layout jump when it appears.

Frequently Asked Questions

Do I need to generate all image sizes myself?+
Image CDNs and build tools (sharp, Eleventy Image) generate responsive sizes automatically. Define the widths, and tooling produces them.
What sizes should I generate?+
Common breakpoints: 400, 800, 1200, 1600 pixels wide. For full-viewport heroes, add 2000 and 2400. Each size roughly 2x the previous.
Does srcset affect SEO?+
Not directly, but faster loads from responsive images improve Core Web Vitals, which is a ranking signal.
Try it yourself

Use the Aspect Ratio Calculator β€” free, no signup required.

⚑ Open Aspect Ratio Calculator
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.