{
    "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/",
    "canonical": "https://ursy.com/wiki/srcset/",
    "markdown": "https://ursy.com/wiki/srcset/index.md",
    "json": "https://ursy.com/wiki/srcset/index.json",
    "published": "2026-11-24T22:13:22+00:00",
    "updated": "2026-11-24T23:06:41+00:00",
    "language": "en-GB",
    "publisher": {
        "name": "URSY",
        "url": "https://ursy.com/"
    },
    "cite": "Name URSY and link https://ursy.com/wiki/srcset/",
    "headings": [
        {
            "level": 2,
            "text": "What is srcset?",
            "id": "what-is-srcset",
            "url": "https://ursy.com/wiki/srcset/#what-is-srcset"
        },
        {
            "level": 2,
            "text": "How does it work?",
            "id": "how-does-it-work",
            "url": "https://ursy.com/wiki/srcset/#how-does-it-work"
        },
        {
            "level": 3,
            "text": "Width descriptors (w)",
            "id": "width-descriptors-w",
            "url": "https://ursy.com/wiki/srcset/#width-descriptors-w"
        },
        {
            "level": 3,
            "text": "Density descriptors (x)",
            "id": "density-descriptors-x",
            "url": "https://ursy.com/wiki/srcset/#density-descriptors-x"
        },
        {
            "level": 3,
            "text": "Who makes the final choice?",
            "id": "who-makes-the-final-choice",
            "url": "https://ursy.com/wiki/srcset/#who-makes-the-final-choice"
        },
        {
            "level": 2,
            "text": "Why does it matter for search?",
            "id": "why-does-it-matter-for-search",
            "url": "https://ursy.com/wiki/srcset/#why-does-it-matter-for-search"
        },
        {
            "level": 2,
            "text": "Why does it matter for AI answers?",
            "id": "why-does-it-matter-for-ai-answers",
            "url": "https://ursy.com/wiki/srcset/#why-does-it-matter-for-ai-answers"
        },
        {
            "level": 2,
            "text": "srcset or the picture element?",
            "id": "srcset-or-the-picture-element",
            "url": "https://ursy.com/wiki/srcset/#srcset-or-the-picture-element"
        },
        {
            "level": 2,
            "text": "Common mistakes",
            "id": "common-mistakes",
            "url": "https://ursy.com/wiki/srcset/#common-mistakes"
        },
        {
            "level": 2,
            "text": "A worked example",
            "id": "a-worked-example",
            "url": "https://ursy.com/wiki/srcset/#a-worked-example"
        },
        {
            "level": 2,
            "text": "How to check it",
            "id": "how-to-check-it",
            "url": "https://ursy.com/wiki/srcset/#how-to-check-it"
        },
        {
            "level": 2,
            "text": "Questions",
            "id": "questions",
            "url": "https://ursy.com/wiki/srcset/#questions"
        },
        {
            "level": 3,
            "text": "Does srcset replace src?",
            "id": "does-srcset-replace-src",
            "url": "https://ursy.com/wiki/srcset/#does-srcset-replace-src"
        },
        {
            "level": 3,
            "text": "Does WordPress add srcset for me?",
            "id": "does-wordpress-add-srcset-for-me",
            "url": "https://ursy.com/wiki/srcset/#does-wordpress-add-srcset-for-me"
        },
        {
            "level": 3,
            "text": "Is srcset a ranking factor?",
            "id": "is-srcset-a-ranking-factor",
            "url": "https://ursy.com/wiki/srcset/#is-srcset-a-ranking-factor"
        },
        {
            "level": 2,
            "text": "Related words",
            "id": "related-words",
            "url": "https://ursy.com/wiki/srcset/#related-words"
        },
        {
            "level": 2,
            "text": "Sources",
            "id": "sources",
            "url": "https://ursy.com/wiki/srcset/#sources"
        }
    ],
    "links": [
        {
            "text": "reference for the img element",
            "url": "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img",
            "internal": false
        },
        {
            "text": "responsive images",
            "url": "https://web.dev/learn/design/responsive-images",
            "internal": false
        },
        {
            "text": "page speed",
            "url": "https://ursy.com/wiki/page-speed/",
            "internal": true
        },
        {
            "text": "Largest Contentful Paint",
            "url": "https://ursy.com/wiki/largest-contentful-paint/",
            "internal": true
        },
        {
            "text": "Core Web Vitals",
            "url": "https://ursy.com/wiki/core-web-vitals/",
            "internal": true
        },
        {
            "text": "optimising LCP",
            "url": "https://web.dev/articles/optimize-lcp",
            "internal": false
        },
        {
            "text": "Google",
            "url": "https://ursy.com/wiki/google/",
            "internal": true
        },
        {
            "text": "image SEO best practices",
            "url": "https://developers.google.com/search/docs/appearance/google-images",
            "internal": false
        },
        {
            "text": "CSS",
            "url": "https://ursy.com/wiki/css/",
            "internal": true
        },
        {
            "text": "image SEO",
            "url": "https://ursy.com/wiki/image-seo/",
            "internal": true
        },
        {
            "text": "AI crawlers",
            "url": "https://ursy.com/wiki/ai-crawler/",
            "internal": true
        },
        {
            "text": "live fetchers",
            "url": "https://ursy.com/wiki/live-fetcher/",
            "internal": true
        },
        {
            "text": "alt text",
            "url": "https://ursy.com/wiki/alt-text/",
            "internal": true
        },
        {
            "text": "large language model",
            "url": "https://ursy.com/wiki/large-language-model/",
            "internal": true
        },
        {
            "text": "answer engine optimisation",
            "url": "https://ursy.com/wiki/answer-engine-optimisation/",
            "internal": true
        },
        {
            "text": "WebP and AVIF",
            "url": "https://ursy.com/wiki/webp-and-avif/",
            "internal": true
        },
        {
            "text": "layout shift",
            "url": "https://ursy.com/wiki/cumulative-layout-shift/",
            "internal": true
        },
        {
            "text": "lazy loading",
            "url": "https://ursy.com/wiki/lazy-loading/",
            "internal": true
        },
        {
            "text": "image resizer",
            "url": "https://ursy.com/webmaster-tools/image-resizer/",
            "internal": true
        },
        {
            "text": "image compressor",
            "url": "https://ursy.com/webmaster-tools/image-compressor/",
            "internal": true
        },
        {
            "text": "Core Web Vitals checker",
            "url": "https://ursy.com/core-web-vitals-checker/",
            "internal": true
        },
        {
            "text": "page speed checker",
            "url": "https://ursy.com/page-speed-checker/",
            "internal": true
        },
        {
            "text": "image SEO checker",
            "url": "https://ursy.com/image-seo-checker/",
            "internal": true
        },
        {
            "text": "broken link checker",
            "url": "https://ursy.com/broken-link-checker/",
            "internal": true
        },
        {
            "text": "Core Web Vitals calculator",
            "url": "https://ursy.com/webmaster-tools/core-web-vitals-calculator/",
            "internal": true
        },
        {
            "text": "WordPress SEO",
            "url": "https://ursy.com/wiki/wordpress-seo/",
            "internal": true
        },
        {
            "text": "user experience",
            "url": "https://ursy.com/wiki/user-experience-ux/",
            "internal": true
        },
        {
            "text": "technical SEO",
            "url": "https://ursy.com/wiki/technical-seo/",
            "internal": true
        },
        {
            "text": "HTML",
            "url": "https://ursy.com/wiki/html/",
            "internal": true
        },
        {
            "text": "Mobile SEO",
            "url": "https://ursy.com/wiki/mobile-seo/",
            "internal": true
        }
    ],
    "words": 1089,
    "text": "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? 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 describes it as a comma-separated list of “possible image sources” for the browser to choose from. web.dev’s lesson on 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? 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) 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) 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? 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? It matters in 2 ways. Speed. Smaller files on small screens help page speed and Largest Contentful Paint, one of the Core Web Vitals. web.dev’s guide to optimising LCP wants the main image’s src or srcset present in the first HTML, so the browser finds it early. Image search. Google’s image SEO best practices 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 background images. More on this in our image SEO guide. Why does it matter for AI answers? AI crawlers and live fetchers read your HTML as text. Many never run your layout, so they see only the attributes. A clear src and an honest alt text tell a 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. 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 Google’s image guide says that with <picture> you should still include an img element with a src as the fallback. 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. Lazy loading the hero image. web.dev’s LCP guide says “Never lazy-load your LCP image”. Keep 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 product page shows a 1600 pixel photo in a column 400 pixels wide on phones. Every phone downloads the full file. The fix: Export 3 widths: 400, 800 and 1600 pixels. Our image resizer and image compressor run in your browser. Write srcset=\"photo-400.jpg 400w, photo-800.jpg 800w, photo-1600.jpg 1600w\". Add sizes=\"(width <= 600px) 100vw, 400px\" to match the real layout. Keep src=\"photo-800.jpg\", plus width, height and alt. 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 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 or the page speed checker once they launch (coming soon). Use our image SEO checker to list images with no src, alt or size. Run the broken link checker to catch missing image files in a list. Our Core Web Vitals calculator explains the thresholds. Questions Does srcset replace src? No. Keep src as the fallback. Google and web.dev both say so. 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. 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 and technical SEO. Related words Image SEO Largest Contentful Paint Lazy loading HTML Mobile SEO Sources MDN: the img element (srcset and sizes), checked 24 November 2026 web.dev: Responsive images, checked 24 November 2026 web.dev: Optimise Largest Contentful Paint, checked 24 November 2026 Google Search Central: Image SEO best practices, checked 24 November 2026 Updated 24 November 2026 by URSY.",
    "source": "https://ursy.com/wiki/srcset/"
}