TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why I dislike the rem unit (2013)

23 pointsby matthbergabout 5 years ago

9 comments

RobertRobertsabout 5 years ago
1. Rem does not need a fallback [1]<p>2. Rem works awesome for making default font sizing. (like a normalize in a way) [2]<p>3. Rem allows us to use a sort of centralized sorta relative sizing that percentage and em just do not fulfill.<p>Rem is awesome, I think this guy just can&#x27;t get passed the &quot;it&#x27;s new and so I don&#x27;t like it&quot; problem.<p>[1] <a href="https:&#x2F;&#x2F;caniuse.com&#x2F;#search=rem" rel="nofollow">https:&#x2F;&#x2F;caniuse.com&#x2F;#search=rem</a><p>[2] <a href="https:&#x2F;&#x2F;snook.ca&#x2F;archives&#x2F;html_and_css&#x2F;font-size-with-rem" rel="nofollow">https:&#x2F;&#x2F;snook.ca&#x2F;archives&#x2F;html_and_css&#x2F;font-size-with-rem</a>
评论 #22553274 未加载
zeroxfeabout 5 years ago
I think many of these don&#x27;t apply today (bugs, fallback support, flexibility.) My current project uses (almost) entirely rem and em units, and it is so much cleaner and easier to manage than the alternatives.
gentleman11about 5 years ago
This blog is written very pleasantly, but is giving advice about sizing units while being two screens wide on my phone and having no right margin. Shrug
wildylionabout 5 years ago
Come on guys, I thought it was about radiation!
评论 #22553592 未加载
philliphaydonabout 5 years ago
Wow. I dislike this blog. If you have a large resolution you get this thin line down the right hand side of your screen.
评论 #22556261 未加载
ravenstineabout 5 years ago
&gt; Unfortunately rems are not supported on certain (older) browsers.<p>Poor argument, especially since IE9 supports them, and IE shouldn&#x27;t be supported anyway. I suppose people needed to back in 2013.<p>&gt; With the rem unit we have a problem though. Since all font-sizes are relative to the root element, the font-size: 90%; rule is completely ignored. We now have to recalculate and override every font-declaration in the aside to get the same result. Spaghetti is wonderful as lunch or dinner, but not as code.<p>At this point, I question whether it&#x27;s even necessary to use percentages for font sizes deeper in the DOM than the root element. Unless the font is going to change at any given viewport width, it&#x27;s easier to just write the font sizes for every screen breakpoint you have. I don&#x27;t know why developers&#x2F;designers make things unnecessarily difficult. Most web designs don&#x27;t necessitate this kind of complexity.<p>&gt; The rem unit is buggy<p>This was fixed years ago. Try it yourself in today&#x27;s Chrome.<p>&gt; Another reason why some people prefer rem over em is because inheritance is hard. I always tell these people they’re doing it wrong.<p>No they&#x27;re not. They&#x27;re using rem to properly support the user&#x27;s right to set the font size in their browser preferences and have it actually work on a webpage. They&#x27;re not using em because they probably don&#x27;t need it. If they didn&#x27;t care about the user&#x27;s font preferences, they&#x27;d probably use px because it&#x27;s easier for everyone to understand.<p>&gt; The inheritance problem occurs when we nest a p in a li. The p will now be 1.2 × 1.2 = 14.4 pixels. This is too big. To make sure that a p in a li is 12 pixels too we now have to write extra, increasingly complex code:<p>So don&#x27;t do that. Write your font sizes explicitly for each element, whether it&#x27;s px or rem.<p>Even better if you use a preprocessor like SCSS that supports variables and mixins, which makes it even simpler to implement &quot;flexible&quot; font sizes without the insanity of making font sizes in elements relative to other parent elements. Even CSS variables that are now becoming ubiquitous help solve these problems.<p>Despite those things, I still insist it&#x27;s possible to avoid these headaches by just not going the em route. They&#x27;re rarely necessary.
paulgpettyabout 5 years ago
The age of the article says a lot; but I think there are overuses of rem, even today, where it’s used for dimensions (width, height, padding, margins) which is not a good idea. Especially when mixed with containing elements that use a mix of em &amp; px units. Where for a while sites were using em &amp; rem, using viewport-percentage lengths is more apprpriate for _both_ font-sizes and dimensions.<p>And for what it’s worth Variable Fonts are a game changer that didn’t exist 7 years ago (along with a whole bunch of new standards and capabilities that make typography and layout so different today), which makes me wish there was a timeline view of all the W3C standards.<p>What’s interesting is that the blog for that article uses a theme with a lot of that new stuff: css vars, flex box, margins &amp; paddings with vh, calc, css grid, font properties that probably aren’t widely supported — so @supports is cool to see, and wait for … it:<p>max-width: calc(30rem * 2);<p>rem units<p>It looks like this is the Author’s own theme:<p><a href="https:&#x2F;&#x2F;vasilis.nl&#x2F;nerd&#x2F;wp-content&#x2F;themes&#x2F;nerd-mississippi&#x2F;style.css?1558868656" rel="nofollow">https:&#x2F;&#x2F;vasilis.nl&#x2F;nerd&#x2F;wp-content&#x2F;themes&#x2F;nerd-mississippi&#x2F;s...</a><p>It seems like it had to have been updated since the article, so indeed maybe he’s softened on rem, if not ...<p>Why use rem if you don’t like it &amp; why use it for 2 max-width declarations? There are a lot of % based dimensions so why not stick with that?<p>I’m not trying to judge, but the if the author created the theme for code consistency and writing consistency that should get cleaned up.<p>There’s also some neat bleeding edg stuff like this:<p>h1 { font-family: &quot;Mississippi Regular&quot;, impact, serif; font-weight: normal; font-size: 15vw; font-size: calc(2em + 14vw); line-height: .7; margin: 0; position: relative; font-size-adjust: .42; }<p>Where those two font-size declarations provide a responsive size where calc is supported … But if you’re using @supports in some places that’s great to use everywhere, for example he uses it here:<p>@supports (font-variant-ligatures: common-ligatures) { body { font-feature-settings: normal; font-variant-ligatures: common-ligatures; } }<p>At some point font-variant-ligatures might be widely supported &amp; using something like postcss could let you purge or optimize that automatically &amp; if manually maintained rules like that just stick out do the road.<p>Rem is awesome, CSS can be painstakingly difficult to keep up with.
chrisseatonabout 5 years ago
How does sizing by pixel work when pixels are wildly different in size. As a designer why do I want text to be half the size for someone on a high resolution screen?
评论 #22552797 未加载
评论 #22552492 未加载
chaoraceabout 5 years ago
This guy sure does love Em-elia