W3C home > Mailing lists > Public > www-svg@w3.org > January 2014

Re: The (new, enhanced) viewbox property

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 6 Jan 2014 14:28:13 -0800
Message-ID: <CAAWBYDCV991-BLK8eFp4JYqFgrbE50L2quwNj9kZvhZ1pR=8CA@mail.gmail.com>
To: "Dr. Olaf Hoffmann" <Dr.O.Hoffmann@gmx.de>
Cc: www-svg <www-svg@w3.org>
On Mon, Jan 6, 2014 at 4:18 AM, Dr. Olaf Hoffmann <Dr.O.Hoffmann@gmx.de> wrote:
> This is not the case for SVG. For SVG 1.1 clearly CSS2.0 applies,

No, CSS applies, the language as it stands, not any obsolete snapshots
of the standard like 2.0.

> only
> CSS 2.1 has the confusing definition:
> 1px is equal to 0.75pt.
> 1pt is equal to 1/72nd of 1in.
> 1in is equal to 2.54cm.
> cm  fortunately is defined as an international standard precisely by
> scientific authorities beyond the competence of the CSS working group,
> inches are derived from this as well, but this fits to the 2.54cm mentioned
> in CSS 2.1.
>
> I haven't seen, that this definition of a pixel is defined in any viewer.
> Usually another misleading section of CSS 2.1 is implemented, that
> promotes to intentionally break international standards of lengths to
> mislead people about the correct size. This needs to be fixed in CSS 2.1,
> but is currently not applicable for SVG 1.1 - therefore viewers having
> such a behaviour have a bug.

Once again, you misunderstand what was actually defined by CSS.  I'm
far past the point of hoping to educate you on this matter, but for
the edification of other readers, here's how CSS deals with units:

It turns out that authors commonly assume that there is a fixed ratio
between the px unit and all the physical units, especially pt.  This
sometimes results in page designs that work when a particular px:pt
ratio is used, but breaks (lines break unexpectedly, floats move
chaotically) when a different one is used.  This means that browsers,
in practice, have to fix a particular ratio of px:pt in order to
render the internet correctly.

The most common ratio, and the one CSS mandates, is 4px = 3pt, due to
most monitors using 96 dpi for many years.

Note that the absolute sizes of the px unit is *not* important here
for pages to render correctly.  Devices have different pixel sizes,
users zoom, etc., and nothing breaks as a result.  So CSS renderers do
have the ability to set the pt unit to its correct physical size (1/72
inch), and thus the size of the px falls out as 1/96 inch.  However,
on computer screens this is often suboptimal - it's best, for
rendering purposes, if the px unit has a simple integer ratio with the
hardware pixels.  As such, browsers tend to fix the size of the px
based on the size of the hardware pixel (making it equal to 1, 2, 3,
etc hardware pixels, depending on resolution), and then the size of
the pt unit (and all the other physical units) follows from that.
This means an element with a width of 1in may not be exactly 1 inch on
screen, but again, given things like browser-zoom, etc., this might
not be true regardless of what the browser does.

(As a further note, there are other interesting constraints on the
size of the px unit.  Many phone screens set the size of the px so
that their screens are exactly 320px wide, to match the iPhone,
regardless of what ratio this has with hardware pixels.  This gives
less pleasing results, but it increases compatibility with
poorly-designed mobile sites.  Luckily these are decreasing as the
share of iPhones as mobile browsers shrinks and the multitude of other
phones increases.)

tl;dr: The ratio of px:pt is fixed at 4:3 for compat/author
expectation reasons, but browsers are free to set the absolute size of
the length units to whatever they need. Some (like printers) can
choose physical accuracy, desktop browsers usually choose a simple
ratio of px:hardware pixels, phone browsers sometimes choose iPhone
compat.

~TJ
Received on Monday, 6 January 2014 22:29:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:35 UTC