Re: [css3-mediaqueries] DPI in resolution media queries

On Feb 16, 2012, at 12:52 pm, Tab Atkins Jr. wrote:

> On Thu, Feb 16, 2012 at 12:11 PM, Lea Verou <leaverou@gmail.com> wrote:
>> Opened netmagazine.com today, found yet another article documenting the
>> problem:
>> http://www.netmagazine.com/features/where-are-our-absolute-css-units
>> The writer seems to be under the impression that this is a browser bug that
>> goes against the spec.
>> 
>> I wonder what exactly is needed to convince you guys that this is a real
>> problem that needs a solution (any solution!).
> 
> There is no problem.  The specs are clear, simple, and more-or-less
> reasonable.  Mobile devices, though, are *astonishingly* buggy and
> wrong-headed about these things.  Note, for example, the "dp" unit
> that the netmag author talks about.  It's defined to be 1/160 of an
> inch.  The CSS px unit is defined to be 1/96 of an inch.  It's the
> *same* unit, just scaled differently.  The problem is that the
> creators of the dp unit have no idea what the px unit actually does,
> and likely assumed that it means "device pixels".
> 
> Having a "true" inch unit would *not* fix the problem that the author
> of the netmag article brings up.  You can, today, get a touch target
> that is at least 8mm square by setting its width and height to 45px.
> (This accounts for the maximum that the CSS in unit can deviate from a
> physical inch.)
> 
> The fact that the physical units can deviate up to a third in one
> degenerate case (when the screen is 144dpi) is unfortunate, of course,
> because if you try to account for it you'll get a larger-than-desired
> element in other resolutions (on a 96dpi or 192dpi screen, 45px is
> 12mm).  However, it'll at least be constant with the rest of the page.
> 
> I do support adding a single, small unit that implementations can
> attempt to align with the "real" unit, like truemm.  It should be
> relatively inconvenient to use for most purposes, thus hopefully
> avoiding the exact large-scale breakage that caused us to fix the
> ratio between the px and in units in the first place, but still useful
> for defining touch targets of a particular size.

I think there is a legitimate use case for a media query which is
able to discern the true dimensions of the screen.

Imagine a desktop screen which is 1024x768, and a tablet screen
that has the same pixel dimensions, but is physically much smaller.
Designers may need to style the page differently, or provide different
image assets purely because of the physical size difference. Without
physical length units, how else can they do this?

Simon

Received on Friday, 17 February 2012 03:22:11 UTC