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 trialBryan Thien
10,973 PointsRem 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
969 PointsHi 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
Shay Paustovsky
969 PointsYou 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.
Bryan Thien
10,973 PointsBryan Thien
10,973 PointsSo could you just use rem for mostly everything and then use em when you want a different font size? Thank you for answer :)