This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Hello, this code should displays a div with length of 6cm. <html> <head> <title>Test of width declaration at a DIV</title> </head> <body> <div style="background-color: #000; width: 6cm;">Test</div> </body> </html> But if I measure it is 5.7cm. The same is if I declare a div with 2cm, than I got 1.9cm. Is this a Bug?
I assume you mean that you measured it with a physical ruler against your screen? No, this is not a bug. Web compatibility requires us to fix the ratio between the 'px' and the 'pt' unit. Points, though, are defined in terms of inches, so we had to fix the ratio of 'px' to 'in' as well. Obviously, then, the ratio of 'px' to 'cm' and 'mm' is similarly fixed now. So, all the physical units are worth a constant and unchanging number of 'px' units. We now have two options. First, we could make the physical units correct. However, this would mean that '1px' will usually not be an integer number of device pixels, which makes rendering *very* slow and somewhat unpredictable/fuzzy. Second, we could make the 'px' unit be an integer number of device pixels. However, this would mean that the physical units in CSS aren't quite correct on all screens - in the worst case (a 144dpi screen) they'll be 50% off from "real" units. However, the problem is much smaller on most screens, and gets better as screens get higher resolution. The second option was judged to be much less troublesome for the web. So, using physical units like "6cm" will often produce lengths on the screen that aren't *quite* 6 centimeters.