Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Design Web Typography Final Project: Create a Typographic Site Basic One and Two Column Layouts

Bryan Thien
Bryan Thien
10,973 Points

Rem or Em

Why does he use rem for max-width but the rest he uses em. Is there a good rule of thumb when to use each one?

2 Answers

Shay Paustovsky
Shay Paustovsky
969 Points

Hi Bryan,

I didn't complete the 'Web Typography' course but Guil touches this subject on CSS basics.

The idea is simple:

When you want different font sizes for elements inside a parent element and the parent has a different font size, go with rem because if you use em units then a compounding effect will happen because em units being the relative units they are, are relative to their parent element's font size. If you want to avoid this affect then use rem's

Bryan Thien
Bryan Thien
10,973 Points

So could you just use rem for mostly everything and then use em when you want a different font size? Thank you for answer :)

Shay Paustovsky
Shay Paustovsky
969 Points

You will use rem's when you want the font size to be relative to the root of the document. and em's when you want the font-size to be relative to the parent element of the child. that's while assuming you changed the font size of the parent element.