DEV Community

Cover image for The Battle of the Units: PX vs REM vs EM (font-size)

The Battle of the Units: PX vs REM vs EM (font-size)

Ochuko on September 11, 2022

In this article I'm going to go through a few CSS units for customizing the font-size of text when building webpages. There are a lot of other unit...
Collapse
 
divineee profile image
dee-vine

this was genuinely such a fun and insightful read! 😄 thank you for this

Collapse
 
ochukodotspace profile image
Ochuko

Thank you for taking the time out to read it 😄

Collapse
 
wadecodez profile image
Wade Zimmerman

Yeah apparently rem/em should be avoided in spacing because then everything will scale proportionally to the font size which is the same as just zooming in/out.

Collapse
 
christian_legge profile image
Christian Legge

rem won't scale to the font size unless the root font size (and therefore everything on the page) changes, in which case you should treat it as zooming in/out.

Collapse
 
ochukodotspace profile image
Ochuko

Yes, rem wouldn't scale unless the root font size changes

Collapse
 
lico profile image
SeongKuk Han

If I wanna male a responsive website, is 'rem' better in most cases? I'm looking forward to the next post(padding)!

Collapse
 
ochukodotspace profile image
Ochuko • Edited

They are all good with responsiveness as you can use media queries to define the font-sizes at different breakpoints. However, rem gets credit for the way accessibility is handled.

Collapse
 
lico profile image
SeongKuk Han

Thanks for the answer :)

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

It just depends on the use-case at the end 😅

Collapse
 
raguay profile image
Richard Guay

That was one of the best discussions I’ve read on this subject. Thanks.

Collapse
 
ochukodotspace profile image
Ochuko • Edited

I'm happy you enjoyed it 😅

Collapse
 
brianjay profile image
Brian Williams

This was a nice Sunday read 👏🏾

Collapse
 
ochukodotspace profile image
Ochuko

Thanks. I'm glad you enjoyed it 🤲🏾

Collapse
 
ravavyr profile image
Ravavyr

Great write up, but you didn't cover when to use VW for font sizes.
And if you've never used VW for font sizes...well, you haven't lived yet...or gone crazy...

Collapse
 
ochukodotspace profile image
Ochuko

I had no idea veiwport units were used for typography. Defnitely trying this tonight 😂