srcset -w
syntax, when no source
attribute is setBy deliberately leaving off the otherwise required sources
attribute, we can get some weird browser behaviour. Of course you should not leave off the sources
attribute, this is just to provide a counterpoint as to why it is needed.
The first image has the 320w
but is still missing sizes
.
The second image leaves off the 320w
and is missing the sizes
attribute.
The third image uses -x
syntax as some weird behaviours can occur when both syntax types are on the same page.
<img srcset="img-1920.png 1920w,
img-1280.png 1280w,
img-960.png 960w,
img-640.png 640w,
img-480.png 480w,
img-320.png 320w"
src="img-320.png">
<img srcset="img-1920.png 1920w,
img-1280.png 1280w,
img-960.png 960w,
img-640.png 640w,
img-480.png 480w,
img-320.png"
src="img-320.png">
<img srcset="img-320.png 1x,
img-640.png 2x"
src="img-320.png">