Goodbye ems! I’m Done with Relative Units.

blurry code editor with eyeglasses

I knew it. All along, I knew it.

I think it all boils down to this: there are times when you should use rems and ems — they’re in the spec for a reason. But the scenarios in which you need them are fewer and farther between than the prevailing wisdom would suggest.

So don’t go looking for a reason to use ems and rems. It is enough to what they do. Use pixels, and if a scenario pops up where ems or rems are the better tool for the job, go for it.
David Gilbertson

When I learned to use relative units, ten years ago, it was very necessary. Circa 2007, at a minimum 90% of a website’s traffic was coming from old IE or another browser that didn’t handle scaling well. But after 2010, those numbers started to change drastically.

Ever since, I’ve been toiling away to calculate sizing based on a 16px or 18px base font size. And frankly, it sucks. I’ve hated it. I open my calculator app more times than I blink during a project. Just to figure out what 22 divided by 16 equals. And then what 14 divided by that new parent’s 22 equals.

And then there’s the commenting in the CSS so it’s easy to read and make changes in the future. Somehow I’m doing math and writing out a comment so as to avoid doing math in the future. But if I have to change the size, I’ll HAVE to do the math anyway… so what gives?

You know what I’m talking about. It’s so annoying.

But now I know that I’m not crazy for thinking relative units are an amazing solution to a problem that I never have. I’ve been wanting to go back to pixels for a long time. And I’m finally ready to take the plunge…

Thanks to this awesome editorial by David Gilbertson on Hacker Noon:

rems and ems, and why you probably don’t need them

Look at his other articles too. Really good stuff.