You would use the srcset attribute when you want to serve different images to users depending on their device display width.
For example: <img srcset="small.jpg 500w, medium.jpg 1000w, large.jpg 2000w" src="..." alt="">
tells the browser to display the small, medium or large .jpg graphic depending on the client's resolution.
The first value is the image name and the second is the width of the image in pixels. For a device width of 320px, the following calculations are made:
- 500 / 320 = 1.5625
- 1000 / 320 = 3.125
- 2000 / 320 = 6.25
If the client's resolution is 1x, 1.5625 is the closest, and 500w corresponding to small.jpg will be selected by the browser.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images