What is the srcset attribute in an IMG tag and how to use it?

In short, Srcset is a new attribute which allows you to specify different kind of images for different screen-sizes/orientation/display-types. The usage is really simple, you just provide a lot of different images separating them with a comma like this: <img src=”https://stackoverflow.com/questions/19634463/image.jpg” alt=”image” srcset=”https://stackoverflow.com/<img> <descriptor>, https://stackoverflow.com/…, https://stackoverflow.com/<img_n> <descriptor_n>”>. Here is an example: srcset=”https://stackoverflow.com/image.jpg 160w, https://stackoverflow.com/image2.jpg 320w, … Read more

Is it possible to see which srcset image a browser is using with browser developer tools

The image has a property currentSrc, you can log it or inspect it with several tools: In chrome developer tools inspect the element, then click the properties tab. In Firefox developer tools inspect the element, right click and select DOM from the context menu. You will see an entry for currentSrc: with the actual image … Read more