3 <title>Image srcset attribute example</title>
6 font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
11 background-color: #E2E6F5;
21 border: 1px solid #ccc;
22 background-color: #ddd;
39 The <code>srcset</code> Attribute.
43 Below is a image (<code>img</code>) element with both a regular <code>src</code> attribute
44 as well as a <code>srcset</code> attribute. There is a stylesheet that sets the dimensions
45 of images to 400x400px. On browsers without <code>srcset</code> support, the value of
46 the <code>src</code> attribute will be used as the image src [<a href="image-src.png">default image</a>].
47 On regular resolution displays, the 1x variant of the <code>srcset</code> will be used
48 [<a href="image-1x.png">1x image</a>]. On high resolution displays (at least 2 device pixels per CSS pixel),
49 the 2x variant of the <code>srcset</code> will be used [<a href="image-2x.png">2x image</a>].
52 <img src="image-src.png" srcset="image-1x.png 1x, image-2x.png 2x" alt="Example of the srcset attribute. Image contains a coloured striped pattern with some inline text that indicates which of the candidate images were selected.">
55 The HTML for the above image is:
59 <img src="image-src.png" srcset="image-1x.png 1x, image-2x.png 2x">