W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Fwd: Clarify length units in CSS

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 25 Jul 2008 10:33:49 -0500
Message-ID: <dd0fbad0807250833o5b851a4el3a8230e47998804c@mail.gmail.com>
To: "www-style@w3.org" <www-style@w3.org>
On Fri, Jul 25, 2008 at 9:55 AM, Bert Bos <bert@w3.org> wrote:

>> 1) Should UAs try to match absolute units to the real physical lengths?
>>   (Gecko does; WebKit doesn't)
> Within the constraints of the device, yes. An 'in' is intended to be an
> inch and a 'pt' a point. My experience is that printers nowadays are quite
> accurate. Screens are often a few percent off in the size they report, but
> an 'in' that is only half an inch long is clearly wrong.

Complete agreement, from a web designer.  If I actually have reason to use
an absolute unit, I want it to be an actual absolute unit, or as close as
can be achieved (obviously on some media, like projections, the engine may
not really know what an inch is).

>> 2) Should CSS pixels be treated as absolute or relative?
>>   (WebKit hardcodes 1in==96px; Gecko tries to follow the spec, making
>>    CSS pixels relative, within some restrictions)
> The 'px' unit is meant to provide a size that is small, yet visible, and
> that is reliably displayed, in the sense that you can make a 1px wide rule
> and a 2px wide rule and the second is visibly twice as thick. In addition,
> it was meant to be very easy to implement for browsers in the last century,
> because we wanted browsers to adopt CSS as quickly as possible. We also
> wanted an easy upgrade path for designers who were used to working in pixels
> when it was clear that there would soon be very little uniformity in the
> size of pixels on different devices. Hence we settled on a px that was the
> size of a device pixel of common computer screens at the time, but that was
> nevertheless "safe" for other (and future) devices.
> Printers are so good nowadays, that they can take almost any size and print
> it sharply (as far as the unaided human eye can make out). So if Melinda
> says that 1/96 inch looks more natural than 1/128 inch, then that is fine as
> far as I'm concerned: Melinda's printers can print 1px and 2px wide lines at
> 1/96 inch with no problem.
> But if you put a 200 dpi screen on your desk and the px is displayed as one
> device pixel (1/200 inch), then that is clearly too small, unless you're in
> the habit of reading with your nose against the screen.
> There is no relation between 'in' and 'px' in CSS. Designers who assume
> that 1in is close to (or exactly) 96px may encounter some surprises. On a
> printer or a desktop screen, an 'in' is indeed about a hundred times bigger
> than a 'px', but on a mobile phone there can easily be twice as many 'px' to
> an 'in'; and on some 'projection' media, '1px' may well turn out to be
> bigger than '1in'.
> Absolute units were basically added for printing. That's where they are
> most useful. But there may be reasons to use them on a screen as well.

If it wouldn't break too much on the current web (ignoring the possibility
that the average current website would be displayed on a projector or
something, because it really wouldn't in normal use), I'd prefer a px to
just be identical to whatever unit browsers use when an author specifies the
width/height of an <img> (I suppose this is a device pixel?).  When Units
Level 3 comes in and gives me vw and vh units I'll be able to switch away
from pixels virtually entirely, which will be nice.

Received on Friday, 25 July 2008 15:34:26 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC