4 ms·
Breaking the "cm" units in CSS is inexcusable.
by alextingle 14y ago
Breaking the "cm" units in CSS is inexcusable.
- jrmg 14y agoIt's actually required by the CSS spec[1]: 1px is equal to 1/96th of 1in, 1pt is equal to 1/72nd of 1in So, given that hard requirement, you have three options: - make your hardware have 96 dpi (or a multiple thereof). - have 1 'px' equal to 1 screen pixel (or point) but 'cm', 'in' etc. not equal to real-world centimetres, inches etc. - have 'cm', 'in' etc. identical to real-world centimetres, inches etc., but 'px' without a direct relation to a screen pixel (or point). Apple (and everyone else except perhaps printers) chose the second of those options. [1]http://www.w3.org/TR/css3-values/#absolute-lengths http://www.w3.org/TR/css3-values/#absolute-lengths
- taejo 14y agoIn CSS, px does not have a direct relation to screen pixel. From your reference: > The reference pixel is the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length. For a nominal arm's length of 28 inches, the visual angle is therefore about 0.0213 degrees. For reading at arm's length, 1px thus corresponds to about 0.26 mm (1/96 inch).
- jrmg 14y agoTrue, but, also from there: For lower-resolution devices, and devices with unusual viewing distances, it is recommended instead that the anchor unit be the pixel unit. For such devices it is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel.
- smackfu 14y agoI don't understand why CSS would have both actual lengths, and device pixel lengths, and then define them relative to each other. That makes no sense.
- kybernetikos 14y agoI know. it seems to me that there should be 3 ways of referring to distances and sizes; absolute (px: actual hardware dots not scaled), real world (cm/mm/inches/pt) and relative (100%/0.75).