8 comments

  • somat45 minutes ago
    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 &quot;tut tut, everybody is using px and these new hi-dpi displays are rendering things really tiny, we can&#x27;t have that&quot; and now px as a useful unit is ruined.<p>Is there a way to use real pixels? My, admittedly quick, search says no. at least nothing jumps out at me from the spec.
    • fsmv18 minutes ago
      You could set the CSS zoom property to 1&#x2F;window.devicePixelRatio with JavaScript but I think you can&#x27;t do it with CSS only. If you do that then px is physical px. This doesn&#x27;t include browser zoom though or mobile pinch to zoom. You could also get those with JavaScript but then people would be really confused by the behavior of your website.<p>You definitely can&#x27;t get pure integers though it&#x27;s always a float even if you use whole numbers. It does eventually get rounded before becoming pixels though.
    • notatoad25 minutes ago
      px is still a useful unit. the user&#x27;s operating system applying a scaling fator doesn&#x27;t make it not useful.<p>if the user&#x27;s operating system is configured to draw pixels at a 1:1 ratio, your pixels will be drawn at a 1:1 ratio. if the user&#x27;s operating system is configured to draw pixels at a 2:1 or 3:1 ratio, you as a web developer don&#x27;t get to override that, but you&#x27;re still addressing pixels directly. if you want to write software that manages the user&#x27;s hardware directly without giving them options to override it, the web is probably not the right platform for you.
    • cedilla16 minutes ago
      No one decided to break it, it was 1&#x2F;96th of an inch from the beginning.<p>The problem with different screens having different pixel densities was already present and obvious in 1996.<p>&quot;Real&quot; pixels are useless if you don&#x27;t know anything about the screen you&#x27;re going to render on.
      • mananaysiempre1 minute ago
        It was around 1&#x2F;96&quot; on a conventional PC screen because that was the conventional pixel density for PC screens; it was 1&#x2F;72&quot; (i.e. 1pt) on a conventional Mac screen for the same reason. That was something to deal with already in the GIFs-in-tables era.
      • cedilla13 minutes ago
        Correction: in CSS1, from December 1996, a pixel was defined slightly differently, which works out to 1&#x2F;90th of an inch.
  • theokrueger3 minutes ago
    content-driven websites that aim to be responsive and accessible should use as little size-related styling as possible. fr for containers and rem&#x2F;em for text.
  • microflash1 hour ago
    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.
    • LowTechHN1 hour ago
      Thought a magic number is when you hard code a number in logic instead of pulling from a data source
      • goda9057 minutes ago
        I&#x27;m guessing the GP means the weird results leads to adding magic numbers to get good results.
    • shevy-java58 minutes ago
      Nobody uses ch, let&#x27;s be honest.
  • npn55 minutes ago
    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.
  • cynicalsecurity45 minutes ago
    What happened to em?
    • masfuerte16 minutes ago
      That&#x27;s what I wondered. I found the spec*. I&#x27;d vaguely thought that 1em was the width of &quot;M&quot; but apparently it&#x27;s just the font-size, and the connection between font-size and the actual size of the text is very font dependent.<p>So 1ch is defined to be the advance width of &quot;0&quot; (zero), so it&#x27;s actually telling you something about the current font.<p>* <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;css-values-4&#x2F;#font-relative-lengths" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;css-values-4&#x2F;#font-relative-lengths</a>
  • rado58 minutes ago
    Layout shift when the font loads
    • microflash37 minutes ago
      Not necessarily. See <a href="https:&#x2F;&#x2F;screenspan.net&#x2F;fallback" rel="nofollow">https:&#x2F;&#x2F;screenspan.net&#x2F;fallback</a>
  • awestroke21 minutes ago
    I will not take CSS advice from a website that looks like such utter crap on mobile
  • shevy-java58 minutes ago
    There is no way I will abandon px.<p>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&#x27;s a design flaw in CSS, plain and simple. And the author is thus also wrong. There won&#x27;t be a mass movement of people using &quot;ch&quot;. It would be a good first april article though.