DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Semantic HTML
  • Accessibility (a11y)
  • Forms & Validation
  • Document Metadata & The <head>
  • The Document Object Model (DOM)
  • Character Encoding & Entities
  • Data Attributes & Custom Data
  • Template, Slot & Web Components
  • Responsive Images: Picture, Source & srcset
  • Loading Strategies & Resource Hints
  • The Native Dialog Element
  • Audio, Video & Media APIs
  • SVG Integration & Canvas Basics
  • Advanced Input Types & Datalist
  • Details, Summary, Progress & Meter
  • Global Attributes & Iframe Security
  • Microdata, Schema.org & Structured Data
  • Open Graph & Social Meta Tags
  • Security Headers & CSP in HTML
  • Link Relations & Canonical Tags
← From Beginner to Expert in Fundamentals of Frontend

Responsive Images: Picture, Source & srcset

15 min read
picturesourcesrcsetsizesArt DirectionWebPAVIF

Responsive Images: Serving the Right Image

Images account for ~50% of page weight. Serving correctly sized images is the single biggest performance win for most websites.

Three Approaches

1. srcset + sizes (Resolution Switching)

Let the browser choose the best image based on viewport width and device pixel ratio.

2. <picture> + <source> (Art Direction)

You control which image loads based on media queries — different crops for mobile vs desktop.

3. Format Switching

Serve modern formats (AVIF, WebP) to supporting browsers with JPEG fallback.

Image Format Comparison

FormatSize vs JPEGSupportBest For
JPEGBaselineUniversalPhotos
WebP25-35% smaller95%+Photos + transparency
AVIF50% smaller85%+Photos (best quality/size)
SVGTiny for vectorsUniversalIcons, logos, illustrations

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.