Back to the index.
Responsive images consist of four possible syntaxes: an <img>
tag with srcset x or w, or a <picture>
tag with media queries or file type sources.
The problem on desktop is that it is possible to change the DPR in most browsers by zooming, and the layout viewport width by either zooming or resizing. None of these problems occur on mobile.
This is the desktop table. The mobile table isn’t ready yet.
Last updated on 18 April 2016.
ALL ENTRIES ARE STILL UNDER CONSIDERATION; THIS IS A TEST.
Desktop responsive <img>
tags are in chaos; especially with img-w. Browsers pretty much do as they please. My general advice is to use the <picture>
element if predictable desktop behaviour with zoom and/or resize is important to you.
Method or property | Internet Explorer | Edge 13 | Firefox | Safari | Chrome | Opera | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | 9 | 10 | 11 | 45 Win | 45 Mac | 45 Linux | 9.0.2 | 49 Win | 49 Mac | 36 Win | 36 Mac | ||||||||
srcset x
Test page
|
No | Al |
Yes | Alter |
Static and persistent | ||||||||||||||
Firefox and Safari are straightforward and logical. In Firefox the image is changed whenever the DPR value changes (i.e. when the user zooms). Safari treats DPR as a constant and therefore never changes the image. Their behaviour is thus consistent with their treatment of DPR. In Edge the image is adjusted when you zoom in, but not when you zoom out. Reloading the page restores the correct image in all cases. In Chrome and Opera the image is not adjusted when you zoom; only when you reload. HOWEVER, a reload will always cause the highest-density image in your cache to be displayed, even if the current DPR calls for a lower-density one. |
|||||||||||||||||||
srcset w and sizes
Test page
|
No | Wrong | Al |
Static | Wrong | ||||||||||||||
General note: browsers are allowed to do as they please with img-w. Thus any and all bugs below can be defended by “It’s how we choose to do it.” Whether that makes img-w a useful tool is unclear. Firefox adjusts the image when you resize and zoom, but it has issues at very high or very low zoom levels: although the image size is adjusted correctly, the the image source is not. I haven’t been able to figure out what’s going on. Safari picks the correct image when the page loads, but does not adjust it to zoom or resize. In Edge the image is adjusted when you resize the window to make it larger, but not when you make it smaller. Its reaction to zooming is confused, and I don’t understand it. Reloading the page gives the correct image when you’ve resized, but the zooming problems persist. Chrome and Opera, finally, oh my! Zooming and resizing change the image size, but not necessarily its source. Zooming does nothing to the source. Resizing to make the window larger changes the source; smaller does not. (This is the same as Edge). Finally, when you reload the page you get the largest image that’s currently in the cache. In general I advise you to use the picture element instead, even though it doesn’t work in Safari. |
|||||||||||||||||||
currentSrc
See previous test pages
|
No | Yes | Yes | No | Yes | ||||||||||||||
img.currentSrc The source that’s currently being applied to the image. May change with zooming. |
|||||||||||||||||||
Method or property | Internet Explorer | Edge 13 | Firefox | Safari | Chrome | Opera | |||||||||||||
8 | 9 | 10 | 11 | 45 Win | 45 Mac | 45 Linux | 9.0.2 | 49 Win | 49 Mac | 36 Win | 36 Mac |
The <picture>
element is a safe haven of stability and predictability. The only problem is that it’s not supported in Safari.
Method or property | Internet Explorer | Edge 13 | Firefox | Safari | Chrome | Opera | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | 9 | 10 | 11 | 45 Win | 45 Mac | 45 Linux | 9.0.2 | 49 Win | 49 Mac | 36 Win | 36 Mac | ||||||||
source + media queries
Test page
|
No | Yes | Yes | No | Yes | ||||||||||||||
All browsers handle zooming and resizing correctly. |
|||||||||||||||||||
image formats
Test page
|
No | Yes | Yes | No | Yes | ||||||||||||||
currentSrc
See previous test pages
|
No | Yes | Yes | No | Yes | ||||||||||||||
picture.querySelector('img').currentSrc The source that’s currently being applied to the image. May change with zooming. Note that this is a property of the |
|||||||||||||||||||
Method or property | Internet Explorer | Edge 13 | Firefox | Safari | Chrome | Opera | |||||||||||||
8 | 9 | 10 | 11 | 45 Win | 45 Mac | 45 Linux | 9.0.2 | 49 Win | 49 Mac | 36 Win | 36 Mac |
Desktop browser test array 2.2; February 2016