This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
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.
It reflects the sizes attribute of the <source> element.
A string.
<source
id="el"
src="mediumVideo.mov"
type="video/quicktime"
sizes="(50em <= width <= 60px) 50em,
(30em <= width < 50em) 30em" />
const el = document.getElementById("el");
console.log(el.sizes); // Output: "(50em <= width <= 60px) 50em, (30em <= width < 50em) 30em"
el.sizes = "(50em <= width <= 60px) 100em, (30em <= width < 50em) 60em"; // Updates the sizes value
| Specification |
|---|
| HTML> # dom-source-sizes> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
sizes |
38 | 13 | 38 | 25 | 10.1Thesizes attribute is supported since Safari 9.1. |
38 | 38 | 25 | 10.3Thesizes attribute is supported since Safari on iOS 9.1. |
3.0 | 38 | 10.3Thesizes attribute is supported since WebView on iOS 9.1. |
HTMLImageElement.sizesHTMLSourceElement.mediaHTMLSourceElement.typeHTMLSourceElement.srcHTMLSourceElement.srcset<source><picture><audio><video>
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/sizes