Guide : Responsive Images (srcset)

How to serve responsive images with the srcset and sizes attributes and the picture element, quand to utiliser chaque, and how responsive images fix LCP and CLS sans being a direct ranking signal.

Première publication : 2 juil. 2026 · Dernière mise à jour : 3 août 2026 · Advanced
Langues

Responsive images let le navigateur (via srcset + sizes) or the author (via <picture>) serve the right-sized image per device. srcset/sizes is resolution switching (même image, navigateur picks — a suggestion); <picture> is art direction or format switching (author-dictated crops/formats — a command). La plupart sites seulement besoin srcset/sizes. Ce n’est pas a direct ranking signal and it doesn't modifier ce que Google indexes — Google indexes the src URL — but it's the concrete fix Lighthouse recommends pour oversized images (its "Properly size images" audit fails at a 4KiB gap) and, paired with explicit width/height, it's how vous prevent CLS. Garder texte alternatif identical and image URLs stable à travers breakpoints pour indexation mobile-first. I reuse the exact srcset + width/height pattern from my Ahrefs CLS article. Nests sous the Image SEO hub.

TL;DR — Two jobs, un syntax family. srcset/sizes on <img> = resolution switching (même image, navigateur picks best-fit — a suggestion); <picture> = art direction or format switching (author-dictated crops/formats — a command). La plupart sites seulement besoin the premier. Responsive images are pas a direct ranking signal and don’t modifier ce que Google indexes — Google indexes the src URL, so garder alt text, filenames, and image URLs stable à travers breakpoints (indexation mobile-first). The réel payoff is Core Web Vitals: right-sizing images is the fix behind Lighthouse’s “Properly size images” audit (fails at a 4KiB gap), and width/height (or aspect-ratio) — pas srcset — is ce que empêche CLS. Don’t lazy-load the LCP image. I reuse the exact srcset + width/height pattern from my Ahrefs CLS 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 différent jobs, un syntax family

Everything in ce topic collapses into two mechanisms, and half the confusion out là comes from mixing les up:

  1. Resolution switching — the même image at différent sizes or pixel densities. Vous give le navigateur a menu with srcset and sizes on the <img>, and the navigateur decides qui fichier to récupérer fondé on the viewport and screen density. Ce is the courant cas.
  2. Art direction — a genuinely différent image per condition: a wide crop on desktop, a tight vertical crop on mobile, or a différent fichier format entirely. Ici vous dictate the choice with the <picture> element.

The web.dev Apprendre: Responsive images course frames the difference exactly correct: with srcset le navigateur obtient suggestions, whereas “the picture element gives commands.” And the scope-setting line worth tattooing on the wall, aussi from web.dev: “Vous probably won’t besoin to utiliser the picture element pour la plupart of votre responsive images — the srcset and sizes attributes on the img element cover a lot of utiliser cas.” Reach pour <picture> seulement quand vous en réalité besoin a différent image, pas a différent size of the même un.

srcset and sizes — resolution switching

w-descriptors vs. x-descriptors

srcset takes a comma-separated liste of candidate fichiers, chaque tagged with a descriptor. Là are two kinds:

  • Width descriptors (w) — vous state chaque file’s intrinsic pixel width (puppy-2000.jpg 2000w). Le navigateur combines que with votre sizes valeur to fonctionner out qui fichier meilleur fits the space and the device’s pixel density. Ce is the flexible option and ce que you’ll utiliser la plupart of the temps.
  • Pixel-density descriptors (x) — vous state qui fichier is pour qui device pixel ratio (logo.png 1x, logo@2x.png 2x). Utiliser ces pour fixed-size images (an avatar, a logo) où the affiché size jamais changements; vous don’t besoin sizes with x descriptors.

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

Pourquoi sizes matters (and ce que se produit si vous skip it)

With w descriptors, sizes isn’t optional cosmetics — it’s how le navigateur knows how big the image va render so it peut choisir avant layout. Per web.dev, sizes “indique le navigateur ce que size vous expect the image to be affiché at sous différent conditions,” as a comma-separated liste of media conditions and widths:

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

Lire it as: “si the viewport is 600px or narrower, the image va be à propos de 480px wide; sinon, à propos de 1000px.” Omit sizes and le navigateur assumes the image fills the complet viewport width (100vw) — so on a wide screen it may pull votre largest fichier pour an image that’s en réalité rendering at 400px, quietly defeating the whole point. Manquant sizes is the unique la plupart courant srcset mistake.

Don’t guess at ceux width valeurs from the layout in votre head — vérifier the image’s réel rendered CSS width in le navigateur (DevTools → Elements → the computed width of the <img> box) at chaque breakpoint vous care à propos de, and définir sizes to match. A sizes valeur que doesn’t match the réel rendered width encore causes the navigateur to select the incorrect candidate même though the markup is syntactically correct — syntax validation alone won’t catch que; voir the currentSrc vérifier ci-dessous to confirmer ce que en réalité chargé.

Worked exemple (my reusable pattern)

Ce is the exact pattern from my Ahrefs piece, Ce que Is Décalage cumulatif de mise en page (CLS) & How To Améliorer 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 l’URL Google indexes; srcset listes the candidates with w descriptors; sizes indique le navigateur the rendered width; width/height reserve space (the CLS fix — plus ci-dessous); alt stays identical aucun matter qui fichier loads.

The picture element — art direction and format switching

Quand vous en réalité besoin it

Utiliser <picture> pour two choses srcset can’t do:

  1. Art direction — a différent crop per breakpoint. web.dev’s exemple: on a narrow phone vous pourrait serve a tall, tight crop; on a wide desktop, a short, wide un. Même subject, deliberately différent framing.
  2. Format switching — offer AVIF/WebP with a JPEG fallback via <source type="…">, letting le navigateur prendre the premier format it supports. Ce ties straight back to the format guidance on the Image SEO hub.

The syntax (and the fallback rule)

The <picture> element wraps un or plus <source> elements and toujours 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>

Que trailing <img src> n’est pas optional. Google states it directement: per section 4.8.1 of the HTML Standard, “assurez-vous que vous provide an img element as a fallback with a src attribute quand en utilisant the picture element.” It’s the fichier older navigateurs and robots d’exploration fall back to — and, à nouveau, the un Google indexes.

Fait srcset aider SEO? Direct vs. indirect

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

Directement: aucun. Responsive-image markup n’est pas a ranking signal the façon texte alternatif or filenames are pour recherche d’images. Ajout srcset doesn’t lift votre positions, and it doesn’t modifier ce que apparaît in Google Images. Google indexes the image referenced in src; the srcset/<picture> variants are a delivery mechanism, pas separately indexable assets. Garder votre alt text, filename, and données structurées attached to que principal src image.

Indirectly: yes, and it’s un of the biggest levers vous have. Right-sized images are the la plupart effective concrete fix pour two Core Web Vitals — LCP and CLS — qui feed Google’s page-experience signals. That’s the whole payoff. It’s the même shape as the WebP/AVIF story on the Image SEO hub: aucun boost pour the format itself, the win is speed.

Responsive images and LCP

Oversized images are un of the la plupart courant causes of a slow Largest Contentful Paint, and responsive images are Lighthouse’s recommended fix. The Lighthouse “Properly size images” audit listes “tout images in votre page que aren’t appropriately sized, along with the potential savings” — anything bigger than it needs to be “simplement results in wasted bytes and slows bas page charger temps.” Its fix, verbatim: “With responsive images, vous generate multiple versions of chaque image, and alors specify qui version to utiliser in votre HTML or CSS en utilisant media requêtes, viewport dimensions, and so on.”

Two specifics worth knowing:

  • The échec threshold is 4KiB. Lighthouse seulement flags an image quand “the rendered size is au moins 4KiB plus petit que the réel size.” Petit overshoots don’t count; serving a 3000px fichier into a 400px slot fait.
  • A tooling shortcut. Google recommends RespImageLint, “a utile bookmarklet pour identifying the optimal srcset and sizes valeurs pour votre images.” Run it avant vous hand-calculate breakpoints.

Don’t lazy-load the LCP image

Ce is the rule personnes break la plupart. srcset on votre hero is fine — but jamais pair it with lazy chargement on the LCP element. The largest above-the-fold image devrait charger eagerly with fetchpriority="high", exactly as the Image SEO hub covers. And quand vous construire a responsive <picture> hero, garder the swap logic native: Google warns que it “won’t load content that requires user interactions” comme swiping or clicking, so a JS scheme que seulement loads the réel image après interaction hides it from Google.

Responsive images and CLS

Here’s the trap: srcset alone ne fait pashing pour layout shift. Resolution switching decides qui fichier loads; it doesn’t reserve space pour it. Left sans dimensions, per web.dev’s Optimize CLS guide, “as images load, text shifts down the page to make room for them” — parce que the space “can’t be allocated pour it jusqu’à le navigateur starts to download it and peut determine its dimensions.”

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

  • Définir width and height attributes on the <img>. Modern navigateurs “définir the par défaut aspect ratio of images fondé on an image’s width and height attributes,” so ceux two numbers reserve the correct box avant quelconque srcset variant downloads. (web.dev)
  • Pair les with height: auto in CSS pour fluid containers. Ce is the partie que semble contradictory but isn’t: web.dev’s propre guidance is to “utiliser CSS to resize the image to the width of the container” and “définir height: auto; to éviter en utilisant a fixed valeur pour the image height.” The HTML attributes définir the intrinsic aspect ratio; the CSS lets the image scale fluidly. Ensemble ils prevent CLS and stay responsive.
  • Or utiliser CSS aspect-ratio to reserve the space quand vous pouvez’t définir attributes.

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

Indexation mobile-first implications

Google indexes primarily the mobile version of votre pages, so two rules matter plus que ils utilisé to quand you’re serving responsive variants:

Google’s propre summary of pourquoi to bother is plain: “designing responsive web pages leads to meilleur utilisateur experience, since personnes peut accès les à travers a plethora of device types.”

Ce que à propos de Bing?

There’s aucun Bing-specific guidance on srcset, sizes, or the <picture> element — Bing’s public documentation doesn’t adresse responsive-image markup at tout. So don’t justify responsive images with a Bing algorithm hook; the cas is performances and UX, qui Bing (comme Google) treats as page-experience quality plutôt que something vous peut point at a documented responsive-images rule pour.

Erreurs fréquentes

  • Forgetting sizes with w descriptors — le navigateur assumes 100vw and may récupérer votre biggest fichier pour a petit slot.
  • Dropping the fallback src on <picture> — a spec violation Google explicitly flags, and it’s l’URL robots d’exploration index.
  • Mismatched width/height ratio vs. the actually-served image — encore causes shift.
  • Lazy-loading the LCP hero — delays LCP pour aucun raison; charger it eagerly with fetchpriority="high".
  • Regenerating image URLs per requête — breaks Google’s mise en cache and the mobile-first “stable URL” rule.
  • Reaching pour <picture> quand srcset/sizes voudrait do — unnecessary complexity; web.dev dit la plupart sites don’t besoin it.

Où ce sits

Ce is the sizing-and-delivery deep dive sous the broader Image SEO hub — the performances half of image SEO, parallel to how the texte alternatif guide handles the image-search half. Pour the layout-shift mechanics in complet, voir my Ahrefs CLS article; pour LCP, fetchpriority, and the chargement strategy, that’s Core Web Vitals fonctionner 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.