So, here is my first question on Stack Overflow. It sounds perhaps kind of silly, but I’m wondering how accurate the Absolute Length Units (in, cm, mm, pt, pc) are.
I use now since years pixel for the height, margins, padding, indents, and so on, of elements. The problem I somehow have is that pixel are only more or less accurate. The CSS specification recommends a “reference pixel” of roughly 90ppi. So far so good. But every screen has different ppi values. Some going down to 72 other go far higher then the 90.
This fact shows me that using pixels is not very accurate and I’m thinking about switching over to Absolute Units. It sounds silly, but I want to know if a mm for example has exactly the same size on every screen, or are there also differences from screen to screen, how big a mm is?
This question is not a joke. I can’t find anything about this topic and want to know if I can optimize my layout in the high end when using another Unit than pixel.
Thank you in advance for sharing your knowledge.
Physical units are useless, (broadly) because it’s impossible to programatically determine the DPI of a screen.
I’ve got a 23″ 1080p monitor, which gives me a DPI of 95. But the only thing the browser knows about is the viewport size, and I can change that at any time, by resizing the browser window or changing the monitor resolution. You could assume that all 1080p panels have a 23 inch diagonal, but Newegg tells me that you can get a 1080p monitor in any size between 21.5″ and 27″. This doesn’t even count HDTVs which come in a wide, wide range of sizes, all at the exact same display resolution.
The Windows API exposes monitor DPI, except it lies, and you can’t trust the numbers it gives you.
So, basically, you can only use physical units when you control the display device, like a printer. For the web, it’s a waste of time.