Responsive Images Serving Perfect Pixel Size
No more blurry images on Retina displays or 5MB monsters on mobile. The ultimate guide to 'srcSet', 'sizes', and Art Direction on the web.
Responsive Images: Always Serving the Perfect Pixel Size
A picture is worth a thousand words. But on the web, a picture often says: "I'm 4 MB big and consuming your entire monthly data plan."
The problem: Devices are extremely diverse. The iPhone user has a "Retina" display with 3x pixel density. They need crisp images. The user with the old Android on a 3G network needs a small, heavily compressed image that loads quickly. If you serve both the same image ("Desktop Size"), you make one of them unhappy.
The solution is called Responsive Images. It is one of the most powerful, but most frequently misunderstood features in HTML.
Featured Snippet: Responsive Images allow the browser to automatically select the appropriate image file depending on screen size and pixel density (DPI). With the attributes
srcSet(list of available resolutions) andsizes(display width), the device loads only the pixels it really needs. This saves bandwidth and massively speeds up loading.
The Cost of Inaction: Pixel Waste
If you load a 1920px wide image onto a phone that is physically only 375px wide (but has 2x pixel density, so needs 750px):
- Over-Download: You load 1200 pixels too much width. The file is 4x larger than necessary.
- CPU Load: The phone has to decode and downscale the huge image in memory. This eats battery and makes scrolling jerky.
A study by HTTP Archive shows: Images make up 60% of web traffic. Whoever optimises here has the biggest performance lever.
The Tool: Syntax in Detail
Resolution Switching (Same Image, Different Sizes)
The standard problem: "Load small on mobile, large on desktop."
<img src="small.jpg"
srcset="small.jpg 500w, medium.jpg 1000w, large.jpg 2000w"
sizes="(max-width: 600px) 100vw, 50vw"
alt="A great image">
What happens here?
srcset: We tell the browser: "Here are 3 versions of the image (500, 1000, 2000 pixels wide). Take what you need."sizes: We say: "On small screens, the image fills the screen (100vw), on large screens it is only half as wide (50vw)."- Result: The browser calculates: Screen Width x Pixel Density = Required Pixels. And loads ONLY that file.
Art Direction (Different Image Crop)
The problem: A landscape format image looks great on desktop. On mobile, it is so small that you can't recognise anything. Here we want to load a portrait image or a zoom ("crop") on mobile.
We use the <picture> element for this.
<picture>
<source media="(max-width: 799px)" srcset="portrait-crop.jpg">
<source media="(min-width: 800px)" srcset="landscape-wide.jpg">
<img src="landscape-wide.jpg" alt="Landscape">
</picture>
Here we force the browser to take the portrait image on small screens. This is a design tool, not a purely performance tool.
Automation: No One Does This by Hand
"Do I have to save every image in 5 sizes now?" God forbid, no. Your build system or an Image CDN does that.
- Next.js Image Component:
<Image src="/img.jpg" />. Next.js automatically generates all sizes and formats (WebP/AVIF) at build time. You don't have to do anything. - Cloudinary / Imgix:
You upload one master image.
The URL
image.com/my-pic?w=500generates the 500px version in real-time.
Workflow 2026: Developers define only the logic ("How wide is the image displayed?"), machines generate the pixels.
Myth-Busting: "Retina Needs Double Resolution"
Designers often say: "Export everything in @2x."
That is true, but it is dangerous.
If you deliver everything in @2x, users with poor screens (old laptops) suffer.
Responsive Images solve this elegantly: A Retina screen takes the 2000w image, a standard screen the 1000w image.
No one gets too much, no one too little.
Unasked Question: "What About Lazy Loading?"
Images that lie "Below the Fold" (i.e., only visible after scrolling) should not load immediately.
Previously, you needed JavaScript libraries.
Today it is native in HTML: loading="lazy".
<img src="..." loading="lazy">
The browser loads the image only when the user scrolls near it. This saves massive data initially.
Attention: Never put loading="lazy" on the Hero Image (the top image)! This delays the LCP (Largest Contentful Paint) and harms SEO. Always load the top image eager.
FAQ: Image Best Practices
Why are my images blurry?
Probably you set the sizes attribute incorrectly. If you tell the browser "The image is displayed 200px wide", but it really shows at 800px, it loads a version that is too small. Always check if sizes matches the CSS.
Is AVIF better than WebP?
Yes, AVIF compresses approx. 20-30% smaller than WebP at the same quality. It should be the standard format today (2026), with WebP/JPG as fallback for ancient browsers.
How do I deal with SVGs?
Vector graphics (logos, icons) need no Responsive Images (srcset). They are "infinitely" scalable and always sharp. Use SVGs for everything that is not photos.
What is "Layout Shift"?
When an image loads and the text below it jumps away, Google hates that ("Cumulative Layout Shift"). Always give images inside HTML width and height attributes (or use CSS Aspect-Ratio) so the browser reserves the space before the image is loaded.
Internal Linking
Related Articles:
MyQuests Frontend Team
Founder & Digital Strategist
Olivier Jacob is the founder of MyQuests Website Management, a Hamburg-based digital agency specializing in comprehensive web solutions. With extensive experience in digital strategy, web development, and SEO optimisation, Olivier helps businesses transform their online presence and achieve sustainable growth. His approach combines technical expertise with strategic thinking to deliver measurable results for clients across various industries.
Related Articles
App Store Optimization For Pwas
Read more about this topic App Store Optimization For Pwas β Mobile-First & Progressive Web Apps
Designing Touch Friendly Interfaces
Read more about this topic Designing Touch Friendly Interfaces β Mobile-First & Progressive Web Apps
Future Mobile Web Standards Html6
Read more about this topic Future Mobile Web Standards Html6 β Mobile-First & Progressive Web Apps
