srcset
and pixel density descriptors<img alt="A test responsive image" src="fallback.png" srcset="600x600.png 1x, 1200x1200.png 2x, 1500x1500.png 3x" />
The pixel density descriptor of srcset
lets you tell the browser what image should be used
depending on the device pixel ratio. If there are 1x, 2x or 3x device pixels to CSS pixels then the corresponding
image will be chosen.
You can see the device pixel ratio in the information in the top right of the screen under
devicePixelRatio
.
Note that the actual width of the device or window does not affect the calculation, only the device pixel ratio.
The width of the image element take the pixel density account when determining its size. The equation is:
image element width = width of the source image / pixel density
For the examples above: