Responsive Images
Also Known As
srcset
picture element
art direction
image sizes
TL;DR
Serving different image sizes to different devices using srcset and sizes — preventing mobile devices from downloading desktop-sized images.
Explanation
The srcset attribute provides multiple image sources with width descriptors (300w, 600w, 1200w). The sizes attribute tells the browser the display size at each viewport width. The browser picks the most appropriate source. The picture element enables art direction — different crops for different screens. The modern stack: generate WebP and AVIF variants, use srcset for density/size selection, and use picture for format selection with fallback. Tools: Imagemagick, sharp (Node), imgproxy, Cloudinary.
Common Misconception
✗ CSS max-width: 100% makes images responsive — CSS only scales the display; the browser still downloads the full-resolution image; srcset controls what gets downloaded.
Why It Matters
A mobile user downloading a 2400×1600 hero image sized 400×267 in CSS wastes 6× the bandwidth — srcset ensures they download the appropriately sized image.
Common Mistakes
- srcset without sizes — browser assumes full viewport width and picks too large an image.
- No WebP/AVIF fallback in picture element — older browsers see nothing without the fallback img.
- Same image at different sizes without art direction — portrait images need different crops, not just scaling.
- Not pre-generating images server-side — on-the-fly resizing is slow; cache generated variants.
Code Examples
✗ Vulnerable
<!-- One large image for all devices:
<img src="hero-2400w.jpg" alt="Hero" style="max-width:100%">
<!-- Mobile: downloads 2400px image, displays at 400px — 6x wasted bandwidth -->
✓ Fixed
<!-- srcset for resolution switching:
<img
srcset="hero-400w.webp 400w, hero-800w.webp 800w, hero-1600w.webp 1600w"
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 800px"
src="hero-800w.jpg"
alt="Hero"
loading="eager" fetchpriority="high"
width="800" height="400">
<!-- picture for format + art direction:
<picture>
<source media="(max-width:600px)" srcset="hero-mobile.avif" type="image/avif">
<source media="(max-width:600px)" srcset="hero-mobile.webp" type="image/webp">
<source srcset="hero-desktop.avif" type="image/avif">
<img src="hero-desktop.jpg" alt="Hero">
</picture>
References
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
16 Mar 2026
Edited
22 Mar 2026
Views
26
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 1
No pings yesterday
Perplexity 7
Amazonbot 6
SEMrush 3
Google 2
Ahrefs 1
Also referenced
How they use it
crawler 18
crawler_json 1
Related categories
⚡
DEV INTEL
Tools & Severity
🟠 High
⚙ Fix effort: Medium
⚡ Quick Fix
Use srcset with w descriptors and a sizes attribute — the browser selects the right image size for the viewport; PHP generates the multiple resized versions on upload
📦 Applies To
any HTML5
web
🔗 Prerequisites
🔍 Detection Hints
Single large image served to all screen sizes; mobile downloading desktop-size images; no srcset on product or hero images
Auto-detectable:
✓ Yes
lighthouse
pagespeed-insights
⚠ Related Problems
🤖 AI Agent
Confidence: Medium
False Positives: Medium
✗ Manual fix
Fix: Low
Context: File