XML technologies / CSS / Advanced websites with CSS / Behind the scenes / Measurements / Absolute values
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The following table lists all units available for absolute values in CSS syntax, with their meanings.
Table: Units for absolute values in CSS.
Abbreviation | Meaning | Explanation |
|---|---|---|
| Inch | 2.54 cm |
| Centimeter | |
| Millimeter | |
| Point | 1/72 inch |
| Pica | 12 points or 1/6 inch |
| Pixel | A dot on the screen |
A zero length needs no unit. 0px is as valid in CSS syntax as simply 0, regardless of the unit.
Any length unit in the table can specify an element’s absolute size or position in a style rule. For example, the following property definitions produce the same result:
font-size: 1in;
font-size: 2.54cm;
font-size: 25.4mm;
font-size: 72pt;
font-size: 6pc;Pixels behave quite differently. Pixel font sizes create a stable size ratio between text and images across graphics resolutions and monitor sizes. A pixel is a screen dot that can be switched on or off and displayed in any color. At a resolution of 800 x 600 pixels, for example, one pixel is 1/600 of the screen height. A typical 15-inch monitor has a display about 10.5 inches high and just over 13 inches wide. (Note: the resolution’s aspect ratio of 9 to 12 inches might seem to imply the same physical display ratio. However, computer monitors slightly stretch their contents horizontally for better character readability, producing the 10.5-to-13-inch ratio.) A 12-pixel font appears 1/5 inch high, occupying 1/50 of the visible area.
Many designers set font sizes in pixels, believing this prevents users from resizing text in browser preferences simply because Internet Explorer cannot do so. Most other browsers can scale even pixel-sized fonts. A familiar problem appears on pages whose developers have not realized this: text often spills out of its box. For accessibility, we should help users enlarge text regardless of their browser. We should therefore avoid pixel font sizes.
Building pages that still work when users change browser font sizes is part of web design. Avoid defining font sizes in pixels.
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg
back to top