[whatwg] srcset isn't future-friendly to screen size differences
Fred Andrews
fredandw at live.com
Fri Sep 7 04:25:21 PDT 2012
> From: simonp at opera.com
...
> On Fri, 07 Sep 2012 06:07:30 +0200, Fred Andrews <fredandw at live.com> wrote:
>
> >
> >
> >> From: jackalmage at gmail.com
> > ...
> >> I'm not sure how best to solve this, but John Mellor suggested
> >> allowing the specification of the image's native dimensions somehow.
> >> That way, the browser could know that the 1600.jpg image is
> >> appropriate to serve as an 800px wide high-dpi image, or a 1600px wide
> >> low-dpi image.
> >
> > John has a proposal here:
> > http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-August/036958.html
> > e.g. '<img srcset="320x120, 320.jpg 1x, 640.jpg 2x, 1280.jpg 4x,
> > 2560.jpg 8x">' . As I understand it John's proposal only declares the
> > image sizes and is not intended for making a selection based on density
> > or screen size directly?
>
> If what's necessary here is to declare the intrinsic dimensions, why not
> use the width="" and height="" attributes for this? (They can be
> overridden with CSS if you want e.g. 100% width.)
The aim is to declare the available raw image sizes so that the browser can choose the most appropriate image to use. That is, the image 320x120.jpg is 320 pixels wide and 120 pixels high, the image 640.jpg is 640 pixels wide and 240 pixels high, etc. This is not intended to specify the CSS pixel size the that image will occupy. The width="" and height="" attributes may well be used to specify the CSS pixel size of the image in the layout. If the width and height of the <img> element are not given then the browser will need to consult the raw image size and I presume John intends the first size to be the CSS pixel size in this case - for higher density screens the browser could then choose a higher resolution image from the set.
There are a few other proposals with a similar intent.
cheers
Fred
More information about the whatwg
mailing list