[whatwg] Implementation complexity with elements vs an attribute (responsive images)

Kornel Lesiński kornel at geekhood.net
Mon May 14 15:04:48 PDT 2012

On Mon, 14 May 2012 01:30:20 +0100, Odin Hørthe Omdal <odinho at opera.com>  

> All optional replacements of the src will have to be fitted in the same
> box as the original src. That might actually require you to specify both
> width and height upfront. Of course, people won't really do that, so I
> guess we're bound to get differing behaviour... Hm.
> What do people think about that? What happens here? You have no info on
> the real size of the picture. I guess maybe the browser should never
> load any srcset alternatives then? If you have no information at all
> it's rather hard to make a judgement.
> A photo gallery wants to show you a fullscreen picture, and give you:
>    <img src=2048px.jpg srcset="4096px.jpg 2x">
> In this example, us (humans :P) can easily see that one is 2048 px and  
> the other 4096 px. If I'm viewing this on my highres Nokia N9, a naïve
> implementation could pick the 2x, because it knows that's nicely highres
> just like its own screen.
> But it would actually be wrong! It would never need anything else than
> the 2048 px for normal viewing because it is anyway exceeding its real
> pixels on the screen.

If srcset/<picture> provides authors with good way to serve images at most  
appropriate size, they won't need to resort to tricks with downsizing  
high-res images to smaller size.

For a full-width image on a ~960px viewport (assuming author doesn't have  
better sizes available) this would be appropriate:

   <img src=2048px.jpg srcset="2048px.jpg 2x, 4096px.jpg 4x"  

regards, Kornel Lesiński

More information about the whatwg mailing list