srcset and sizesBaseline · Widely available
The srcset and sizes attributes for <img> elements set a list of possible sources for the image and a corresponding list of size conditions for choosing a source, to show a responsive image that fits the size of the display.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Mar 27, 2017. Widely available since Sep 27, 2019.
Browser support
DesktopChrome
1–37Not supported
38+Supportedsince Oct 7, 2014
Current: 155Edge
12–12Not supported
13+Supportedsince Nov 12, 2015
Current: 154Firefox
1–37Not supported
38+Supportedsince May 12, 2015
Current: 157Safari
1–10Not supported
10.1+Supportedsince Mar 27, 2017
Current: 27MobileChrome Android
18–37Not supported
38+Supportedsince Oct 8, 2014
Current: 155Firefox Android
4–37Not supported
38+Supportedsince May 12, 2015
Current: 157Safari iOS
1–10Not supported
10.3+Supportedsince Mar 27, 2017
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
HTML
<img src="photo-800.jpg" srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1600.jpg 1600w" sizes="(max-width: 600px) 100vw, 50vw" alt="…">
Feature detection
JS · check before using
if ("HTMLImageElement" in globalThis && "srcset" in HTMLImageElement.prototype) {
// HTMLImageElement.srcset is available
}Specification
Usage share
Sub-features
Support for each part of the feature (8). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| HTMLImageElement.sizes | 38 | 13 | 38 | 9.1 | 38 | 38 | 9.3 |
| HTMLImageElement.srcset | 34 | 12 | 38 | 8 | 34 | 38 | 8 |
| HTMLSourceElement.sizes | 38 | 13 | 38 | 10.1 | 38 | 38 | 10.3 |
| HTMLSourceElement.srcset | 38 | 13 | 38 | 10.1 | 38 | 38 | 10.3 |
| img.sizes | 38 | 12 | 38 | 9.1 | 38 | 38 | 9.3 |
| img.srcset | 34 | 12 | 38 | 8 | 34 | 38 | 8 |
| source.sizes | 34 | 13 | 38 | 9.1 | 34 | 38 | 9.3 |
| source.srcset | 34 | 13 | 38 | 9.1 | 34 | 38 | 9.3 |