<picture>
<source
id="el"
srcset="smile.png, smile-1.5x.png 1.5x, smile-2x.png 2x"
type="image/png" />
</picture>HTMLSourceElement: srcset property / notebook
HTMLSourceElement: srcset property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const el = document.getElementById("el");
console.log(el.srcset); // Output: "smile.png, smile-1.5x.png 1.5x, smile-large 800w"
el.srcset = "smile.png, smile-med.png 600w, smile-large.png 800w"; // Updates the srcset value