by ardemue · 12y ago · 0 comments
An example from the homepage:
<picture>
<source media="(min-width: 40em)" srcset="big.jpg 1x, big-hd.jpg 2x">
<source srcset="small.jpg 1x, small-hd.jpg 2x">
<img src="fallback.jpg" alt="">
</picture> <img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w">
Can someone explain the drawbacks?To authors it wasn't clear whether "w" declared width of the image, or min-width or max-width media query.
It's a media query, but doesn't look like one. Values look like CSS units, but aren't.
On top of that interaction between "w", "h" and "x" was arbitrary with many gotchas, and everybody assumed it works differently.
With <picture> we have full power of media queries using proper media query syntax.
srcset is still there in a simplified form with just 1x/2x, and that's great, because it is orthogonal to media queries ("art direction" case) and processed differently (UA must obey MQ to avoid breaking layouts, but can override srcset to save bandwidth).
If I understood your question correctly.
HTML keeps getting pulled in so many directions. I wish XHTML had won. It was modular, pluggable, extensible, and semantic. The last bit might have eventually made entering the search space easy for new competitors, too.
But the browser vendors failed to make a stand against bad HTML.
<img>
<srcset>
<source><width>1024</width><src>large-image.jpg</source>
<source><width>512</width><src>small-image.jpg</source>
</srcset>
<src>image.jpg</src> <*>fallback</*>
<alt>My image</alt>
</img> <picture>
<srcset media="(min-width: 40em)">
<source size="1x" src="big.jpg" />
<source size="2x" src="big-hd.jpg" />
</srcset>
...another srcset...
<img src="fallback.jpg" />
</picture>
Fractionally more verbose, but really a lot less fiddly.