[whatwg] srcset isn't future-friendly to screen size differences
Tab Atkins Jr.
jackalmage at gmail.com
Fri Sep 7 09:36:52 PDT 2012
On Fri, Sep 7, 2012 at 9:21 AM, Hans Muller <hmuller at adobe.com> wrote:
> On 9/6/12 6:36 PM, "Tab Atkins Jr." <jackalmage at gmail.com> wrote:
>>Consider the following example:
>><img srcset="800.jpg 1x, 1600.jpg 2x" style="width: 100%; height: auto;">
>>For a screen that's somewhere near 800px wide, this works just fine.
>>However, a 1x screen 1600px wide (not too uncommon - I think a 19"
>>monitor is roughly that width) will get served the 800.jpg image,
>>which then gets blown up to an unattractive level.
> In this particular case, without considering other display densities,
> wouldn't this suffice:
> <img src="1600.jpg" srcset="800.jpg 800w 1x, 1600.jpg 800w 2x"
> style="width: 100%; height: auto;">
That's basically equivalent to what I wrote. I just added an
additional (technically superfluous) 1x to the final declaration. The
problem, as I noted, is that it means you're duplicating the
"1600.jpg" url, which is a minor editting hazard. This kind of
"solution" also only works in this specific case, when you're only
dealing with two densities and no art direction.
More information about the whatwg