logoalt Hacker News

Death to px, long live ch

47 pointsby Brajeshwartoday at 1:56 PM39 commentsview on HN

Comments

somattoday at 2:56 PM

What I want to know is who decided to break px, the last thing we need is yet another screwball physical measurement, css was already full of them. But what "tut tut, everybody is using px and these new hi-dpi displays are rendering things really tiny, we can't have that" and now px as a useful unit is ruined.

Is there a way to use real pixels? My, admittedly quick, search says no. at least nothing jumps out at me from the spec.

microflashtoday at 2:29 PM

I’ve found that ch and ex units are heavily influenced by latin characters. They just give weird results with non-latin characters leading to magic numbers. But the concept is really solid: use them if you want the spacing relative to text.

show 2 replies
npntoday at 2:46 PM

I also did some experiment with ch many years ago. I found that 60ch is ideal width for block text for easy reading. too bad it is pretty hard to make websites with only 60ch wide.

larussotoday at 5:41 PM

I’m somewhat out of the loop but I remember the time everybody switched from px to em’s. When I came back to CSS for a short while it was px again and behold it worked for 4K screens. To be honest I didn’t really liked the usage of em and actually prefer px.

squidlibtoday at 4:33 PM

I’d like to hear the author’s approach to vw and vh units. I’ve tended to use these units where I want a specific feel and it’s worked relatively well over the years. I’m surprised it was not mentioned given the justifying of ch was around the desire of a consistent layout.

jeberletoday at 4:12 PM

I'm still waiting for operating systems to adopt true physical units. You know, that trick PostScript printers have doing since the 80s (running at 300dpi no less). I realize there are large screen projectors in the wild, that's solvable problem. Bitmaps icons are also an issue, but again, solvable.

cynicalsecuritytoday at 2:55 PM

What happened to em?

theokruegertoday at 3:37 PM

content-driven websites that aim to be responsive and accessible should use as little size-related styling as possible. fr for containers and rem/em for text.

radotoday at 2:43 PM

Layout shift when the font loads

squidlibtoday at 4:31 PM

I’d like to hear the

awestroketoday at 3:19 PM

I will not take CSS advice from a website that looks like such utter crap on mobile

show 1 reply
shevy-javatoday at 2:42 PM

There is no way I will abandon px.

In fact, I think CSS made the wrong decision by proliferating so many things, em, %, px, ch, whatever-else. The human brain is not well-equipped to have so many things for basically the same thing. That's a design flaw in CSS, plain and simple. And the author is thus also wrong. There won't be a mass movement of people using "ch". It would be a good first april article though.