▲ | brainwad 4 days ago | ||||||||||||||||||||||||||||||||||
Not really. All major browsers just use the value the OS gives them, which is usually rounded to 0.5 or 0.25, which helps keep integer CSS px values an integer number of device pixels. So you could be off as much as 12% if you are on a device that rounded down from 1.12 to 1.0. Also, even if they didn't, there's no standard for what the correct DPI should be for a device; it theoretically should depend on viewing distance, but it's impractical to constantly change the screen DPI depending on how far away the user's eyes are :) OP could, however, use a better default than 96 DPI for mobile devices. Most are targeting ~160-ish. | |||||||||||||||||||||||||||||||||||
▲ | chrismorgan 4 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
> All major browsers round this to 0.5 or 0.25, which helps keep integer CSS px values an integer number of device pixels. This is completely false. No browser that I know of does any such thing, nor would it make any sense to do so (nor would it achieve the goal you specify to any meaningful extent). The closest thing that does happen is that browsers use integer fractions of pixels as their basic layout unit: Firefox and its kin sixtieths, Chrome and its kin sixty-fourths. But the rest of your answer is correct; and to add a proper citation: “the reference pixel is the visual angle of one pixel on a device with a device pixel density of 96dpi and a distance from the reader of an arm’s length” <https://drafts.csswg.org/css-values-4/#reference-pixel>. | |||||||||||||||||||||||||||||||||||
|