4 ms·
Ok, but does it matter?
by nthitz 15y ago
Ok, but does it matter?
- wmf 15y agoOnly to people who freak out when they realize that 1 px = 2 pixels on Retina displays.
- tlb 15y agoThat includes me. Making a pixel not be a pixel is surely one of the great pooch-screws of modern standards. 'pt' existed to be resolution-independent.
- wmf 15y agoIf they had set 1 px = 1 pixel, almost all Web pages would be unreadably small. AFAIK, Web designers don't use pt.
- JoshTriplett 15y agoAnd people would have quickly learned to not use "pixel" unless they really mean "pixel".
- wmf 15y agoYou never really mean pixel, so I guess you're arguing for the removal of the px unit completely. (bzbarsky explained this better: http://news.ycombinator.com/item?id=3697227 http://news.ycombinator.com/item?id=3697227 ) Then designers would start asking for a unit that is resolution-independent but always an integer multiple of pixels — essentially px under a different name. The px unit is really useful, but maybe it should have had a different name; it's too late to argue about it now.
- JoshTriplett 15y agoOn the rare occasions where I say "px" rather than some scalable unit, I really do mean pixel. For example, I might use px to specify the width of an element that needs to have exactly the same width as an img tag.
- nitrogen 15y agoOn devices where 1px != 1 device pixel, images should be scaled by the same proportion as the px unit. So, if you set an img to 150px wide, and a div below it to 150px wide, they will be the same width, even if 150px == 300 pixels. I'd be happy to learn of any browsers where that is not the case.
- JoshTriplett 15y agoIf I wanted an image scaled, I'd give it a size in em or similar, not in px.
- nitrogen 15y agoHTML is a text markup language, not a device interface language. CSS is a page layout language. HTML and CSS are designed for optimum user control as well as designer flexibility. You assume you're designing for one type of device. Designers before you have assumed 96dpi for web pages. The W3C realize these assumptions, realize that the user may want to use a different type of device, and thus define px in terms of DPI. As others have mentioned, if a user prints a web page on a 1200dpi printer, your 960px fixed layout is 4/5ths of an inch wide. Your users would not be pleased. Under the device-centric interpretation of px, you'd have to provide a medium-specific style sheet for every possible type of output device. Designers would not be pleased. Maybe you're trying to use HTML+CSS as a rendering target for a general purpose widget library like Gtk+. In that case, I can understand your frustration.
- colanderman 15y agoI'm not a web designer. Can you explain to me why it's important to be able to position/size something to exactly N pixels, rather than to exactly kN pixels (where k is some integer decided by the browser implementor)?
- mikeklaas 15y agoThe biggest reason is that most css properties ignore fractional px values—you can't draw a .5px border, for instance.
- evincarofautumn 15y agoWhich is absurd, because antialiasing exists for that very reason. I should be able to render a single-pixel-thick vertical line between two columns of display pixels, and get two columns of display pixels at 50% (apparent) brightness. Subpixel rendering would be even better.
- bzbarsky 15y agoThis is only true in some UAs. Gecko has supported fractional pixel values for years in general, though for borders in particular the width is clamped to integer _device_ (not CSS) pixels. WebKit has been rounding them at parse time (even in cases when 1 CSS px is multiple device pixels) for a while, but they're about to fix that. I believe that IE also supports subpixel layout. Not sure about Opera, offhand.
- tlb 15y agoImages and <canvas> and <embed> use actual pixels. It's hard to make things look right when you don't have the same unit in CSS.
- wmf 15y agoMaybe I'm misunderstanding, but I don't think this is correct; the browser should scale everything. See http://joubert.posterous.com/crisp-html-5-canvas-text-on-mobile-phones-and http://joubert.posterous.com/crisp-html-5-canvas-text-on-mob... for example.
- kwamenum86 15y agoI think the important part is that setting something to be 1000px wide does not mean it will take up 1000 pixels on a 1000 pixel wide screen.
- JoelSutherland 15y agoIncreasingly. To my knowledge, all desktop browsers ignore this spec and treat each pixel as a pixel. (This will likely change with the upcoming Retina Macbook Pros) For a while all mobile devices treated all pixels as a pixel. But then iOS and Android devices began to dramatically increase their DPI. In the case of iOS, the math is easy, everything gets multiplied by 2 (though chasing pixel precision in a browser does still require hacks [1]). Android is much more fragmented (go figure). System-wide, there is a DPI setting that influences the viewport pixel-size that the browser claims. For a 800x480 screen, a 1.5x multiplier is used. The browser advertises the mobile-standard 320px viewport width. For the most part, this is good because websites are easier to design for and look roughly as designed on more devices. On ultra-high DPI devices, they even appear pixel-precise. The problem is on the very common mid-dpi devices like the millions of 4" 800x480 devices out there. Pixel-level control is lost, and the pixels are large enough for this to be visible. Some people don't care about pixel-level design precision, some people do. Most people, though, will recognize that a webpage looks not-quite-perfect even if they can't put a finger on it. We're almost out of the woods on phones as DPI is quickly approaching the upper 200's across the board. Unfortunately we're just entering it for non iOS tablets. [1] http://bradbirdsall.com/mobile-web-in-high-resolution http://bradbirdsall.com/mobile-web-in-high-resolution
- voyou 15y ago"all desktop browsers ignore this spec and treat each pixel as a pixel" That's not ignoring the spec, though, it's following it. Where the device pixel is close to the reference pixel (as it is, on desktop browsers), the px measurement is supposed to represent one device pixel. See the CSS 2.1 spec: http://www.w3.org/TR/CSS2/syndata.html#length-units http://www.w3.org/TR/CSS2/syndata.html#length-units
- Stratoscope 15y ago> To my knowledge, all desktop browsers ignore this spec and treat each pixel as a pixel. Not really. Most desktop browsers support pixel scaling with Ctrl+Plus and Ctrl+Minus or user preferences, and they may even remember this setting for each domain. So not only is a CSS pixel not always a device pixel, but it may be a different (fractional) number of device pixels on different websites.