HTMLImageElement: srcset property - Web APIs | MDN
Value
A string. For more information about the syntax of the srcset attribute, see the HTML <img> reference.
Examples
Setting the srcset attribute
js
const img = new Image();
img.srcset =
"/en-US/docs/Web/HTML/Reference/Elements/img/clock-demo-400px.png 2x, /en-US/docs/Web/HTML/Reference/Elements/img/clock-demo-200px.png";
img.alt = "An example picture";
Specifications
| Specification |
|---|
| HTML # dom-img-srcset |