Serving the same full-size image to a phone screen and a 4K desktop monitor is one of the most common, and most fixable, sources of wasted bandwidth on the web. The srcset attribute solves this — letting the browser pick the right-sized image for each visitor’s actual screen, automatically.
Table of Contents
Responsive Images and srcset
Want to try it yourself? Compress your images free — no upload, no signup.
The Problem Responsive Images Solve
A single <img> tag traditionally points to one file:
<img src="photo-large.jpg" alt="Description">
If photo-large.jpg is sized for a large desktop display, every visitor downloads that same large file — including someone on a phone, where the image displays at a fraction of the size and most of that downloaded data is simply wasted, never actually rendered at full resolution.
How srcset Works
srcset lets you offer the browser several versions of the same image at different resolutions (see MDN’s guide to responsive images for the full technical reference), along with a description of your layout, and the browser picks the most appropriate one for that specific visitor’s screen:
<img
src="photo-800.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw, 800px"
alt="Description">
Breaking this down:
srcsetlists each available version with its actual pixel width (400wmeans that file is 400 pixels wide)sizestells the browser how large the image will actually display at different viewport widths — in this example, full-width on screens under 600px, and a fixed 800px otherwisesrcremains as a fallback for browsers that don’t supportsrcsetat all (extremely rare today, but harmless to include)
The browser combines its own screen size, pixel density, and the sizes hint to calculate which file in srcset best fits, then downloads only that one — not all of them.
Responsive Images and Srcset Example
Here is a concrete example:
Say you have a blog featured image that displays at a maximum of 1200px wide on desktop, but full-width (which might only be 380px) on a typical phone. Without srcset, every visitor downloads the full 1200px version. With it:
<img
src="hero-1200.jpg"
srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w"
sizes="(max-width: 480px) 100vw, (max-width: 1024px) 90vw, 1200px"
alt="Blog post hero image">
A phone visitor downloads the ~400px version — a fraction of the file size — while a desktop visitor still gets the full 1200px version. Same markup, right-sized image for everyone.
The Simplest Approach: CSS-Only Responsive Images
Before reaching for srcset, it’s worth knowing the simplest technique of all — a single CSS rule:
img {
max-width: 100%;
height: auto;
}
This makes any image shrink to fit its container on smaller screens, and it’s genuinely enough for a lot of simple sites. What it doesn’t do is reduce the actual file downloaded — a phone visitor still downloads the full-size image, just displayed smaller. This is exactly the gap srcset closes: CSS controls display size, srcset controls which file actually downloads. Frameworks like Bootstrap bundle this same CSS behavior into a class (.img-fluid), which is why it may look familiar if you’ve used one.
The <picture> Element: A Different Kind of Responsive Image
srcset on an <img> tag solves one problem: serving the same image at different resolutions. The <picture> element solves a different, related problem: serving genuinely different images — or different formats — depending on the situation.
Format-switching (the most common use):
<picture>
<source srcset="photo.avif" type="image/avif">
<source srcset="photo.webp" type="image/webp">
<img src="photo.jpg" alt="Description">
</picture>
The browser picks the first format it supports, from top to bottom, falling back to the plain <img> if nothing else matches. This is how you can offer AVIF and WebP to browsers that support them while still guaranteeing a JPG fallback for anything that doesn’t.
Art direction (a genuinely different image per screen size, not just a resized one):
<picture>
<source media="(max-width: 600px)" srcset="photo-cropped-square.jpg">
<img src="photo-wide.jpg" alt="Description">
</picture>
This is different from srcset‘s resolution-switching — here, the phone version isn’t just a smaller copy of the same image, it’s a differently cropped one (say, a tight square crop instead of a wide landscape shot), because what looks right at a wide desktop size doesn’t always look right on a narrow phone screen.
Rule of thumb: use srcset on a plain <img> when you just need different sizes of the same image. Reach for <picture> when you need different formats, or an actually different crop/composition per screen size.
Do You Need to Set This Up Manually?
Usually not, if you’re on WordPress. Since WordPress 4.4, srcset and sizes are generated automatically for any image uploaded through the Media Library, based on the image sizes WordPress creates on upload (thumbnail, medium, large, and full, plus any additional sizes your theme registers). This is genuinely one of those cases where the platform handles a fairly technical optimization for you by default.
Where manual srcset still matters:
- Custom-coded sections outside the standard content editor (a custom homepage template, for instance)
- Background images set via CSS, which
srcsetdoesn’t apply to at all — those need a separate technique (image-set()in CSS, though support and behavior varies) - If you’re hand-coding a static site or web app without WordPress handling it for you
Checking Whether It’s Actually Working
- View a page’s source (or Inspect an image element)
- Look for a
srcsetattribute on the<img>tag — if it’s present with multiple file references, responsive images are active - To confirm the browser is actually using it correctly, open Chrome DevTools → Network tab, throttle to a mobile viewport size, and reload — you should see a smaller file requested than what a desktop viewport would trigger
If your WordPress images have no srcset at all, something may be interfering — a page builder that hand-codes <img> tags without preserving it, or a caching/optimization plugin misconfigured to strip attributes it shouldn’t.
Ready to shrink your images?
Compress and resize JPG, PNG, and WebP files for free, right in your browser. No uploads, no signups, no waiting.
Compress Images Now →Frequently Asked Questions
What is a responsive image?
An image that adapts to the visitor’s screen — either by displaying at a different size (CSS), or by having the browser download a different, better-fitting file depending on the device (srcset and <picture>).
How to make a responsive image?
On WordPress, upload through the Media Library and it happens automatically. Hand-coding it yourself means adding srcset and sizes to your <img> tag (covered above), or wrapping it in a <picture> element if you need format-switching or a different crop per screen size.
How to use responsive images to reduce the image download size?
This is specifically what srcset does — without it, every visitor downloads the same full-size file regardless of their screen. With it, a phone visitor downloads a smaller version automatically, which is the actual bandwidth savings responsive images provide.
Does srcset replace the need for image compression?
No — they solve different problems. Compression reduces the file size of each individual image; srcset makes sure the right-sized image is chosen in the first place. You want both: properly compressed images at each of the sizes offered in srcset.
Is srcset the same as lazy loading?
No, and they’re commonly confused. Lazy loading controls when an image downloads; srcset controls which version downloads. They work well together — a responsive image can also be lazy-loaded, and often is by default in WordPress.
Why does WordPress create so many image sizes on upload?
Each registered size (thumbnail, medium, large, full, plus any theme-specific sizes) becomes a candidate in the srcset list, giving the browser more precise options to choose from across different devices. This does mean more files stored on your server per upload, which is a reasonable, standard trade-off for better-optimized delivery.
Whatever base image you upload, make sure it starts properly compressed — free and instantly, with our browser-based tool — since every size WordPress generates from it inherits the same compression quality as the original.

