For more info: see project home.
source
elements using both media
and srcset
attributesThis markup pattern is further detailed in the original proposal by Florian Rivoal.
This syntax combines the resolution switching of srcset
with picture
’s ability to tailor sources to the viewport. This has a couple of major benefits over the originally-propsed picture
element:
min-device-pixel-ratio
. Determining viewport-appropriate sources is handled through media
attributes as expected, while serving that viewport-appropriate source at the correct resolution is done with srcset
.1x
source to the higher-resolution sources rather than simply delivering an image twice the size. This polyfill simply divides the image’s intrinsic width against the screen resolution (1x, 2x, etc.), though I’m sure this can be handled more intelligently in a native implementation.srcset
allows us to define a set of suggested sources based on resolution, while a user setting or automated bandwidth detection in the browser could still intervene. This approach prevents us from breaking the intended “absolute” terms of media queries.source
elements using media
attributes onlyDoes not perform any resolution switching.