W3C home > Mailing lists > Public > public-html@w3.org > July 2015

Re: srcset Attribute

From: Mat Marquis <mat@matmarquis.com>
Date: Fri, 17 Jul 2015 11:16:59 -0400
Cc: public-html@w3.org
Message-Id: <E481676B-E9DF-4F1A-99DA-441C5E30C3F3@matmarquis.com>
To: Mark Simon <mark@manngo.net>

On Jul 16, 2015, at 11:35 PM, Mark Simon <mark@manngo.net> wrote:

> I am mulling over the srcset attribute, which for many developers in responsive design is the answer to a prayer.
> However, there is one part of the specification which has me befuddled:
> 	An image candidate string consists of the following components, in order, with the further restrictions described below this list:
> 	…
> 	Zero or one of the following:
>         	A width descriptor, …
> 		A pixel density descriptor, …
> As far as I can tell, this means that you can specify the width or the density, but not both. I cannot see the benefit of this restriction, and I can suggest that it renders the specification less than complete.

When widths are specified in conjunction with `sizes`, the browser is able to decide on the most appropriate image source for the user’s viewport size _and_ pixel density—using the `w` syntax, density is already covered.

The 1x/2x syntax is a shorthand for situations where the size of the image in the layout isn’t likely to change. Rather than allowing the browser to decide which source is most appropriate for its size _and_ density, it suggests a source that should be applied given a specific condition. If we were to allow use of both syntaxes at once, we’d be mixing _instructions_ to the browser (1x/2x/etc.) with heuristics that allow the browser to decide which source is most appropriate for itself. For all the complication this would add to the processing algorithm, we wouldn’t be adding anything not already covered by the `w` syntax.

> For example, four candidate devices: an old iPhone, a newer (retina screen) iPhone, and older MacBook, a newer (retina screen) MacBook. It seems that it is not possible to distinguish between all four devices individually, and so one or more of them will need to render a non-optimal image.

The `w` syntax accounts for all these contexts in terms of both viewport size and pixel density; no worries there. https://ericportis.com/posts/2014/srcset-sizes/ is a really good in-depth guide to using the `srcset`/`sizes` syntax, but the short version is that `w` syntax accounts for the size of the image in the layout (using `sizes`), pixel density, and someday additional factors like bandwidth and/or a user preference to determine the source most appropriate for that user—but as it stands right now, the only things factored into those decisions are the image’s size and the user’s screen density.

> I would like to propose an amendment to  the specification to read:
> 	Zero, one or two of the following:
> This would allow the specification of both the width and the density, and allow the developer more flexibility in responding to various screen properties.
> Best Regards,
> Mark
> --
> Mark Simon
> Manngo Net Pty Ltd
> mobile:0411 246 672
> email:mark@manngo.net web:http://www.manngo.net
> Resume:http://mark.manngo.net

Received on Friday, 17 July 2015 15:17:25 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:46:14 UTC