The srcset Attribute.

Below is a image (img) element with both a regular src attribute as well as a srcset attribute. There is a stylesheet that sets the dimensions of images to 400x400px. On browsers without srcset ../support, the value of the src attribute will be used as the image src [default image]. On regular resolution displays, the 1x variant of the srcset will be used [1x image]. On high resolution displays (at least 2 device pixels per CSS pixel), the 2x variant of the srcset will be used [2x image].

Example of the srcset attribute. Image contains a coloured striped pattern with some inline text that indicates which of the candidate images were selected.

The HTML for the above image is:

    <img src="image-src.png" srcset="image-1x.png 1x, image-2x.png 2x">