---
title: "srcset"
description: "srcset lists several sizes of one image so the browser loads the best fit. Learn w and x descriptors, sizes, and the mistakes that slow pages."
url: https://ursy.com/wiki/srcset/
updated: 2026-11-24T23:06:41+00:00
publisher: URSY (https://ursy.com/)
cite: Name URSY and link https://ursy.com/wiki/srcset/
---

# srcset

> srcset lists several sizes of one image so the browser loads the best fit. Learn w and x descriptors, sizes, and the mistakes that slow pages.

**srcset is an HTML attribute on an image that lists several versions of the same picture, at different widths or pixel densities, so the browser can download the one that best fits the screen.** A phone gets a small file, a large high-density screen gets a sharp one, and nobody downloads more bytes than they need.

## What is srcset? {#what-is-srcset}

A normal image tag has one file in its `src` attribute. Every visitor gets that file, whatever their screen. `srcset` adds a list of candidates. MDN’s [reference for the img element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img) describes it as a comma-separated list of “possible image sources” for the browser to choose from.

web.dev’s lesson on [responsive images](https://web.dev/learn/design/responsive-images) puts the key point plainly: srcset “complements the src attribute instead of replacing it”. You still keep a `src`.

## How does it work? {#how-does-it-work}

Each entry in the list is a file address followed by a descriptor. There are 2 kinds of descriptor, and you must pick one kind per list.

### Width descriptors (w) {#width-descriptors-w}

A number followed by `w` gives the real pixel width of that file. MDN says it “must match the intrinsic width of the referenced image”. You pair it with a `sizes` attribute that tells the browser how wide the picture will show on the page.

```
<img src="chair-800.jpg"
  srcset="chair-400.jpg 400w, chair-800.jpg 800w, chair-1600.jpg 1600w"
  sizes="(width <= 600px) 100vw, 50vw"
  width="800" height="600"
  alt="Oak dining chair with a woven seat">
```

Here the picture fills the screen on narrow phones and half the screen elsewhere. The browser does the sum: display width times pixel density, then the nearest file that is big enough.

### Density descriptors (x) {#density-descriptors-x}

A number followed by `x` says which screen density the file is for. It suits images that are always shown at one fixed size, such as a logo.

```
<img src="logo.png" srcset="logo-2x.png 2x" width="120" height="40" alt="Shop logo">
```

MDN notes that with x descriptors, the `src` file counts as the `1x` choice. With w descriptors, `src` is not one of the candidates and `sizes` is used instead.

### Who makes the final choice? {#who-makes-the-final-choice}

The browser. MDN says it “selects any of the available sources at its discretion”, for example to save data on a slow connection. You give options; you do not force one.

## Why does it matter for search? {#why-does-it-matter-for-search}

It matters in 2 ways.

- **Speed.**  Smaller files on small screens help [page speed](https://ursy.com/wiki/page-speed/) and [Largest Contentful Paint](https://ursy.com/wiki/largest-contentful-paint/), one of the [Core Web Vitals](https://ursy.com/wiki/core-web-vitals/). web.dev’s guide to [optimising LCP](https://web.dev/articles/optimize-lcp) wants the main image’s `src` or `srcset` present in the first HTML, so the browser finds it early.
- **Image search.**  [Google](https://ursy.com/wiki/google/)’s [image SEO best practices](https://developers.google.com/search/docs/appearance/google-images) say Google finds images through the `src` of `img` elements. Because “some browsers and crawlers don’t understand these attributes”, Google asks you to always give a fallback `src`. Google also says it does not index [CSS](https://ursy.com/wiki/css/) background images.

More on this in our [image SEO](https://ursy.com/wiki/image-seo/) guide.

## Why does it matter for AI answers? {#why-does-it-matter-for-ai-answers}

[AI crawlers](https://ursy.com/wiki/ai-crawler/) and [live fetchers](https://ursy.com/wiki/live-fetcher/) read your HTML as text. Many never run your layout, so they see only the attributes. A clear `src` and an honest [alt text](https://ursy.com/wiki/alt-text/) tell a [large language model](https://ursy.com/wiki/large-language-model/) what the picture shows. A page full of tiny placeholder files with the real image hidden in script gives them nothing. Keep the real file address in plain HTML. This links to the wider work of [answer engine optimisation](https://ursy.com/wiki/answer-engine-optimisation/).

## srcset or the picture element? {#srcset-or-the-picture-element}

| Need | Use |
| --- | --- |
| Same picture, different sizes | `srcset` with `w` and `sizes` |
| Same picture, fixed size, sharp on retina screens | `srcset` with `x` |
| Different crop for phones (art direction) | `<picture>` with `<source media>` |
| Newer formats with a fallback | `<picture>` with `<source type>`, see [WebP and AVIF](https://ursy.com/wiki/webp-and-avif/) |

Google’s image guide says that with `<picture>` you should still include an `img` element with a `src` as the fallback.

## Common mistakes {#common-mistakes}

- **Leaving out sizes.**  MDN says that without it, `sizes` defaults to `100vw`, the full screen width. A small thumbnail then pulls the largest file.
- **Mixing w and x.**  MDN calls this incorrect. web.dev agrees: one or the other, “but not both together”.
- **Wrong w numbers.**  If the 800w file is really 1600 pixels wide, the browser picks badly.
- **No width and height.**  web.dev says these let the browser keep space, so other content does not jump when the image loads. That jump is [layout shift](https://ursy.com/wiki/cumulative-layout-shift/).
- **Lazy loading the hero image.**  web.dev’s LCP guide says “Never lazy-load your LCP image”. Keep [lazy loading](https://ursy.com/wiki/lazy-loading/) for pictures further down.
- **Percentages in sizes.**  MDN says percentage values are not allowed there. Use `vw` or pixels.

## A worked example {#a-worked-example}

A product page shows a 1600 pixel photo in a column 400 pixels wide on phones. Every phone downloads the full file. The fix:

1. Export 3 widths: 400, 800 and 1600 pixels. Our [image resizer](https://ursy.com/webmaster-tools/image-resizer/) and [image compressor](https://ursy.com/webmaster-tools/image-compressor/) run in your browser.
2. Write `srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1600.jpg 1600w"`.
3. Add `sizes="(width <= 600px) 100vw, 400px"` to match the real layout.
4. Keep `src="photo-800.jpg"`, plus width, height and alt.
5. Because this is the main image, add `fetchpriority="high"`. web.dev warns that setting high priority on more than 1 or 2 images makes it unhelpful.

A phone with a 2x screen now asks for about 800 pixels, not 1600, so it downloads a quarter of the pixels.

## How to check it {#how-to-check-it}

- Open the browser’s developer tools, inspect the image and read its “current source”. Resize the window and watch it change.
- To see LCP for a real page, try the [Core Web Vitals checker](https://ursy.com/core-web-vitals-checker/) or the [page speed checker](https://ursy.com/page-speed-checker/) once they launch (coming soon).
- Use our [image SEO checker](https://ursy.com/image-seo-checker/) to list images with no `src`, alt or size.
- Run the [broken link checker](https://ursy.com/broken-link-checker/) to catch missing image files in a list.
- Our [Core Web Vitals calculator](https://ursy.com/webmaster-tools/core-web-vitals-calculator/) explains the thresholds.

## Questions {#questions}

### Does srcset replace src? {#does-srcset-replace-src}

No. Keep `src` as the fallback. Google and web.dev both say so.

### Does WordPress add srcset for me? {#does-wordpress-add-srcset-for-me}

Most themes that use the built-in image functions print it. Check the page source to be sure. See [WordPress SEO](https://ursy.com/wiki/wordpress-seo/).

### Is srcset a ranking factor? {#is-srcset-a-ranking-factor}

Not by itself. It helps speed and user experience, which feed into how good a page is to use. See [user experience](https://ursy.com/wiki/user-experience-ux/) and [technical SEO](https://ursy.com/wiki/technical-seo/).

## Related words {#related-words}

- [Image SEO](https://ursy.com/wiki/image-seo/)
- [Largest Contentful Paint](https://ursy.com/wiki/largest-contentful-paint/)
- [Lazy loading](https://ursy.com/wiki/lazy-loading/)
- [HTML](https://ursy.com/wiki/html/)
- [Mobile SEO](https://ursy.com/wiki/mobile-seo/)

## Sources {#sources}

- [MDN: the img element (srcset and sizes)](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img), checked 24 November 2026
- [web.dev: Responsive images](https://web.dev/learn/design/responsive-images), checked 24 November 2026
- [web.dev: Optimise Largest Contentful Paint](https://web.dev/articles/optimize-lcp), checked 24 November 2026
- [Google Search Central: Image SEO best practices](https://developers.google.com/search/docs/appearance/google-images), checked 24 November 2026

*Updated 24 November 2026 by URSY.*
