Widely available Suitable for production when it improves semantics, input, or browser integration.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
34
12
38
8
34
8
HTML attribute
sizes
38
12
38
9.1
38
9.3
srcset
34
12
38
8
34
8
sizes
38
13
38
9.1
38
9.3
srcset
38
13
38
9.1
38
9.3
DOM API

The sizes property of the HTMLImageElement interface allows you to specify the layout width of the image for each of a list of media queries, or auto for lazy-loaded images to allow the browser to automatically select an image to display based on the layout size of the element. This allows the browser to choose between different images specified in the…

38
13
38
9.1
38
9.3

The sizes property of the HTMLSourceElement interface is a string representing a list of one or more sizes, representing sizes between breakpoints, to which the resource applies.

38
13
38
10.1
38
10.3

The srcset property of the HTMLSourceElement interface is a string containing a comma-separated list of candidate images.

38
13
38
10.1
38
10.3
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 2 item(s)
Removed
  • This feature was removed in a later browser version (38)
Implementation note
  • Supports a subset of the syntax for resolution switching (using the `x` descriptor), but not the full syntax that can be used with `sizes` (using the `w` descriptor).
Notes 2 item(s)
Removed
  • This feature was removed in a later browser version (38)
Implementation note
  • Supports a subset of the syntax for resolution switching (using the `x` descriptor), but not the full syntax that can be used with `sizes` (using the `w` descriptor).
Notes 2 item(s)
Removed
  • This feature was removed in a later browser version (38)
Implementation note
  • Supports a subset of the syntax for resolution switching (using the `x` descriptor), but not the full syntax that can be used with `sizes` (using the `w` descriptor).
Notes 2 item(s)
Removed
  • This feature was removed in a later browser version (38)
Implementation note
  • Supports a subset of the syntax for resolution switching (using the `x` descriptor), but not the full syntax that can be used with `sizes` (using the `w` descriptor).
Notes 1 item(s)
Implementation note
  • The `sizes` attribute is supported since Safari 9.1.
Notes 1 item(s)
Implementation note
  • The `sizes` attribute is supported since Safari on iOS 9.1.
Notes 1 item(s)
Implementation note
  • The `srcset` attribute is supported since Safari 9.1.
Notes 1 item(s)
Implementation note
  • The `srcset` attribute is supported since Safari on iOS 9.1.

Syntax

HTML
<!-- resolution-based --> <img src="photo-1x.jpg" srcset="photo-1x.jpg 1x, photo-2x.jpg 2x" alt="responsive image"> <!-- viewport width-based --> <img src="photo-800.jpg" srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w" sizes="(max-width: 600px) 100vw, 50vw" alt="responsive image"> <!

Live demo

Responsive image candidates

Pair srcset with a normal img fallback and let the browser choose a candidate.

PreviewFullscreen

Sizes strategy notes

Explain how layout width and candidate widths work together.

PreviewFullscreen

Card with responsive thumbnail

Use srcset inside a content card so the preview scales without changing semantics.

PreviewFullscreen

Use cases

  • Control document behavior

    Use srcset and sizes to influence loading, metadata, or script behavior at the document level.

  • Tune performance strategy

    Apply srcset and sizes when earlier resource hints or document settings improve startup or runtime behavior.

Cautions

  • Test srcset and sizes in your target browsers and input environments before depending on it as a primary behavior.

Accessibility

  • Make sure srcset and sizes supports the intended task without making the page harder to perceive, understand, or operate.