Hacker News new | ask | show | jobs
by teddyh 1494 days ago
> 1px is equal to a single dot in a computer monitor or phone screen.

Far from always!

“For screen displays, it traditionally represents one device pixel (dot). However, for printers and high-resolution screens, one CSS pixel implies multiple device pixels. 1px = 1/96th of 1in.”

https://developer.mozilla.org/en-US/docs/Web/CSS/length

2 comments

The article does talk about this directly after about the sentence you quoted.
But the part the parent commenter quoted is incorrect and the article would be better for having that fixed. The explanation that follows is misleading as well (it's not a "bit of a lie") and would also benefit from not introducing hardware sub-pixels into the discussion (which are irrelevant).
>“For screen displays, it traditionally represents one device pixel (dot). However, for printers and high-resolution screens, one CSS pixel implies multiple device pixels. 1px = 1/96th of 1in.”

And this multiple isn't necessarily an integer, it's specified as a floating point number (though I've in practice only seen fractional parts of .5 (on a samsung galaxy IIRC) )

( https://developer.mozilla.org/en-US/docs/Web/API/Window/devi... )

Blink on Android maps CSS pixels to Android's DP (density-independent pixel) unit, which is derived from a device's "density bucket", which traditionally has been defined by some multiple of 160ppi in .5x increments. There are some oddball values out there (e.g. the "tvdpi" bucket for Android TV apps), but you'll usually see the .5 multiple on phone-sized screens.