Responsive Images (srcset)

How to serve responsive images with the srcset and sizes attributes and the picture element, when to use each, and how responsive images fix LCP and CLS without being a direct ranking signal.

First published: Jul 2, 2026 · Last updated: Jul 18, 2026 · Advanced
demand #5 in Image SEO#40 in On-Page#193 in Technical SEO#267 on the site

Responsive images let the browser (via srcset + sizes) or the author (via <picture>) serve the right-sized image per device. srcset/sizes is resolution switching (same image, browser picks — a suggestion); <picture> is art direction or format switching (author-dictated crops/formats — a command). Most sites only need srcset/sizes. This is not a direct ranking signal and it doesn't change what Google indexes — Google indexes the src URL — but it's the concrete fix Lighthouse recommends for oversized images (its "Properly size images" audit fails at a 4KiB gap) and, paired with explicit width/height, it's how you prevent CLS. Keep alt text identical and image URLs stable across breakpoints for mobile-first indexing. I reuse the exact srcset + width/height pattern from my Ahrefs CLS article. Nests under the Image SEO hub.

TL;DR — Two jobs, one syntax family. srcset/sizes on <img> = resolution switching (same image, browser picks best-fit — a suggestion); <picture> = art direction or format switching (author-dictated crops/formats — a command). Most sites only need the first. Responsive images are not a direct ranking signal and don’t change what Google indexes — Google indexes the src URL, so keep alt text, filenames, and image URLs stable across breakpoints (mobile-first indexingGoogle's practice of using the mobile version of a page's content — crawled by Googlebot smartphone — for indexing and ranking. It is not a separate index and not a ranking boost.). The real payoff is Core Web VitalsGoogle's three real-user UX metrics — LCP (loading), INP (responsiveness), and CLS (visual stability) — used by Google's ranking systems, with no official weight attached, measured on field data.: right-sizing images is the fix behind LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s “Properly size images” audit (fails at a 4KiB gap), and width/height (or aspect-ratio) — not srcset — is what prevents CLSCumulative Layout Shift — a unitless score for unexpected visual movement, taken from the largest burst (session window) of layout shifts, not the lifetime sum. ≤0.1 is good.. Don’t lazy-load the LCPLargest Contentful Paint — render time of the largest visible image or text block, relative to when the page started loading. ≤2.5 s (at the 75th percentile) is good. image. I reuse the exact srcset + width/height pattern from my Ahrefs CLSCumulative Layout Shift — a unitless score for unexpected visual movement, taken from the largest burst (session window) of layout shifts, not the lifetime sum. ≤0.1 is good. piece.

Evidence for this claim The HTML responsive-image features srcset, sizes, and picture let browsers select an appropriate image candidate. Scope: Current HTML responsive image behavior. Confidence: high · Verified: WHATWG HTML: Responsive images Evidence for this claim Google can process responsive images and recommends src as a fallback while using srcset or picture for responsive delivery. Scope: Current Google Images responsive-image guidance. Confidence: high · Verified: Google Search Central: Responsive images

Two different jobs, one syntax family

Everything in this topic collapses into two mechanisms, and half the confusion out there comes from mixing them up:

  1. Resolution switching — the same image at different sizes or pixel densities. You give the browser a menu with srcset and sizes on the <img>, and the browser decides which file to fetch based on the viewport and screen density. This is the common case.
  2. Art direction — a genuinely different image per condition: a wide crop on desktop, a tight vertical crop on mobile, or a different file format entirely. Here you dictate the choice with the <picture> element.

The web.dev Learn: Responsive images course frames the difference exactly right: with srcset the browser gets suggestions, whereas “the picture element gives commands.” And the scope-setting line worth tattooing on the wall, also from web.dev: “You probably won’t need to use the picture element for most of your responsive images — the srcset and sizes attributes on the img element cover a lot of use cases.” Reach for <picture> only when you actually need a different image, not a different size of the same one.

srcset and sizes — resolution switching

w-descriptors vs. x-descriptors

srcset takes a comma-separated list of candidate files, each tagged with a descriptor. There are two kinds:

  • Width descriptors (w) — you state each file’s intrinsic pixel width (puppy-2000.jpg 2000w). The browser combines that with your sizes value to work out which file best fits the space and the device’s pixel density. This is the flexible option and what you’ll use most of the time.
  • Pixel-density descriptors (x) — you state which file is for which device pixel ratio (logo.png 1x, logo@2x.png 2x). Use these for fixed-size images (an avatar, a logo) where the displayed size never changes; you don’t need sizes with x descriptors.

Rule of thumb: fluid, content-width images → w descriptors + sizes; fixed-size UI images → x descriptors.

Why sizes matters (and what happens if you skip it)

With w descriptors, sizes isn’t optional cosmetics — it’s how the browser knows how big the image will render so it can choose before layout. Per web.dev, sizes “tells the browser what size you expect the image to be displayed at under different conditions,” as a comma-separated list of media conditions and widths:

sizes="(max-width: 600px) 480px, 1000px"

Read it as: “if the viewport is 600px or narrower, the image will be about 480px wide; otherwise, about 1000px.” Omit sizes and the browser assumes the image fills the full viewport width (100vw) — so on a wide screen it may pull your largest file for an image that’s actually renderingTurning HTML, CSS, and JavaScript into the final visual page and DOM. at 400px, quietly defeating the whole point. Missing sizes is the single most common srcset mistake.

Don’t guess at those width values from the layout in your head — check the image’s actual rendered CSS width in the browser (DevTools → Elements → the computed width of the <img> box) at each breakpoint you care about, and set sizes to match. A sizes value that doesn’t match the real rendered width still causes the browser to select the wrong candidate even though the markup is syntactically correct — syntax validation alone won’t catch that; see the currentSrc check below to confirm what actually loaded.

Worked example (my reusable pattern)

This is the exact pattern from my Ahrefs piece, What Is Cumulative Layout Shift (CLS) & How To Improve It, expanded with sizes:

<img
  src="puppy-1000.jpg"
  srcset="puppy-1000.jpg 1000w,
          puppy-2000.jpg 2000w,
          puppy-3000.jpg 3000w"
  sizes="(max-width: 600px) 480px, 1000px"
  width="1000" height="1000"
  alt="Puppy with balloons" />

Every piece is load-bearing: src is the fallback and the URL Google indexes; srcset lists the candidates with w descriptors; sizes tells the browser the rendered width; width/height reserve space (the CLS fix — more below); alt stays identical no matter which file loads.

The picture element — art direction and format switching

When you actually need it

Use <picture> for two things srcset can’t do:

  1. Art direction — a different crop per breakpoint. web.dev’s example: on a narrow phone you might serve a tall, tight crop; on a wide desktop, a short, wide one. Same subject, deliberately different framing.
  2. Format switching — offer AVIF/WebP with a JPEG fallback via <source type="…">, letting the browser take the first format it supports. This ties straight back to the format guidance on the Image SEOImage SEO is optimizing the images on your pages so search engines can discover, crawl, index, and rank them — in Google Images and visual search, and as part of standard web results. It spans file format, filenames, alt text, compression, responsive markup, structured data, and image sitemaps. hub.

The syntax (and the fallback rule)

The <picture> element wraps one or more <source> elements and always ends with a plain <img>:

<!-- Art direction: different crop per breakpoint -->
<picture>
  <source media="(max-width: 600px)" srcset="hero-crop-mobile.jpg">
  <img src="hero-crop-desktop.jpg" width="1200" height="675"
       alt="Product hero shot">
</picture>

<!-- Format switching: modern format with a fallback -->
<picture>
  <source type="image/avif" srcset="hero.avif">
  <source type="image/webp" srcset="hero.webp">
  <img src="hero.jpg" width="1200" height="675" alt="Product hero shot">
</picture>

That trailing <img src> is not optional. Google states it directly: per section 4.8.1 of the HTML Standard, “make sure that you provide an img element as a fallback with a src attribute when using the picture element.” It’s the file older browsers and crawlersA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index. fall back to — and, again, the one Google indexes.

Does srcset help SEO? Direct vs. indirect

Here’s the framing every competing guide fumbles, so I’ll be blunt.

Directly: no. Responsive-image markup is not a ranking signal the way alt textAlt text is the value of the `alt` attribute on an HTML `<img>` element — a short text substitute chosen for the image's purpose and context, not a literal description of what it shows. It makes images accessible to screen-reader users and helps search engines understand images, mainly for image search. or filenames are for image search. Adding srcset doesn’t lift your positions, and it doesn’t change what appears in Google Images. Google indexes the image referenced in src; the srcset/<picture> variants are a delivery mechanism, not separately indexable assets. Keep your alt text, filename, and structured dataStructured data is a standardized way of labeling page content (using the schema.org vocabulary in JSON-LD, Microdata, or RDFa) so search engines can understand its meaning. It's not a direct ranking factor — its value is rich results and entity understanding. attached to that primary src image.

Indirectly: yes, and it’s one of the biggest levers you have. Right-sized images are the most effective concrete fix for two Core Web VitalsGoogle's three real-user UX metrics — LCP (loading), INP (responsiveness), and CLS (visual stability) — used by Google's ranking systems, with no official weight attached, measured on field data.LCPLargest Contentful Paint — render time of the largest visible image or text block, relative to when the page started loading. ≤2.5 s (at the 75th percentile) is good. and CLS — which feed Google’s page-experience signals. That’s the whole payoff. It’s the same shape as the WebP/AVIF story on the Image SEOImage SEO is optimizing the images on your pages so search engines can discover, crawl, index, and rank them — in Google Images and visual search, and as part of standard web results. It spans file format, filenames, alt text, compression, responsive markup, structured data, and image sitemaps. hub: no boost for the format itself, the win is speed.

Responsive images and LCP

Oversized images are one of the most common causes of a slow Largest Contentful Paint, and responsive images are LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s recommended fix. The Lighthouse “Properly size images” audit lists “all images in your page that aren’t appropriately sized, along with the potential savings” — anything bigger than it needs to be “just results in wasted bytes and slows down page load time.” Its fix, verbatim: “With responsive images, you generate multiple versions of each image, and then specify which version to use in your HTML or CSS using media queries, viewport dimensions, and so on.”

Two specifics worth knowing:

  • The failure threshold is 4KiB. Lighthouse only flags an image when “the rendered size is at least 4KiB smaller than the actual size.” Small overshoots don’t count; serving a 3000px file into a 400px slot does.
  • A tooling shortcut. Google recommends RespImageLint, “a helpful bookmarklet for identifying the optimal srcset and sizes values for your images.” Run it before you hand-calculate breakpoints.

Don’t lazy-load the LCP image

This is the rule people break most. srcset on your hero is fine — but never pair it with lazy loadingLazy loading defers loading of off-screen or non-critical resources — usually images and iframes — until they're about to enter the viewport. The native way to do it is the loading=\"lazy\" HTML attribute, which needs no JavaScript. on the LCP element. The largest above-the-fold image should load eagerly with fetchpriority="high", exactly as the Image SEO hub covers. And when you build a responsive <picture> hero, keep the swap logic native: Google warns that it “won’t load content that requires user interactions” like swiping or clicking, so a JS scheme that only loads the real image after interaction hides it from Google.

Responsive images and CLS

Here’s the trap: srcset alone does nothing for layout shift. Resolution switching decides which file loads; it doesn’t reserve space for it. Left without dimensions, per web.dev’s Optimize CLS guide, “as images load, text shifts down the page to make room for them” — because the space “can’t be allocated for it until the browser starts to download it and can determine its dimensions.”

The fix is explicit dimensions, and it composes with responsive markup:

  • Set width and height attributes on the <img>. Modern browsers “set the default aspect ratio of images based on an image’s width and height attributes,” so those two numbers reserve the right box before any srcset variant downloads. (web.dev)
  • Pair them with height: auto in CSS for fluid containers. This is the part that looks contradictory but isn’t: web.dev’s own guidance is to “use CSS to resize the image to the width of the container” and “set height: auto; to avoid using a fixed value for the image height.” The HTML attributes set the intrinsic aspect ratio; the CSS lets the image scale fluidly. Together they prevent CLS and stay responsive.
  • Or use CSS aspect-ratio to reserve the space when you can’t set attributes.

Which kills a persistent myth: width/height attributes don’t break fluid layouts. Attributes + height: auto is the correct combo, not a conflict. I walk through the full layout-shift mechanics in my Ahrefs CLS article; the short version is “reserve the space so that there’s no shift” and let the image fill it.

Mobile-first indexing implications

Google indexes primarily the mobile version of your pages, so two rules matter more than they used to when you’re serving responsive variants:

Google’s own summary of why to bother is plain: “designing responsive web pages leads to better user experience, since people can access them across a plethora of device types.”

What about Bing?

There’s no Bing-specific guidance on srcset, sizes, or the <picture> element — Bing’s public documentation doesn’t address responsive-image markup at all. So don’t justify responsive images with a Bing algorithm hook; the case is performance and UX, which Bing (like Google) treats as page-experience quality rather than something you can point at a documented responsive-images rule for.

Common mistakes

  • Forgetting sizes with w descriptors — the browser assumes 100vw and may fetch your biggest file for a small slot.
  • Dropping the fallback src on <picture> — a spec violation Google explicitly flags, and it’s the URL crawlersA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index. index.
  • Mismatched width/height ratio vs. the actually-served image — still causes shift.
  • Lazy-loading the LCP hero — delays LCP for no reason; load it eagerly with fetchpriority="high".
  • Regenerating image URLs per request — breaks Google’s caching and the mobile-first “stable URL” rule.
  • Reaching for <picture> when srcset/sizes would do — unnecessary complexity; web.dev says most sites don’t need it.

Where this sits

This is the sizing-and-delivery deep dive under the broader Image SEO hub — the performance half of image SEO, parallel to how the alt text guide handles the image-search half. For the layout-shift mechanics in full, see my Ahrefs CLS article; for LCP, fetchpriority, and the loading strategy, that’s Core Web VitalsWeb Vitals is Google's initiative (launched May 2020) for unified page-experience quality signals. Core Web Vitals — LCP, INP, and CLS — are the subset used in ranking; the rest (TTFB, FCP, TBT, Speed Index) are diagnostic, not ranking factors. work wearing an image hat.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.