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

CSS CSS Basics Understanding Values and Units Em and Rem Units

I understand the difference between Em and Rem for CSS, but Rem seems easier than getting confused by Em and changing al

I understand the difference between Em and Rem for CSS, but Rem seems easier than getting confused by Em and changing all over and getting confused..

What is the advantage of using Em and stress with the calculation? Is it because different screen have different font size and Em will be able to show layout exactly in all font size and calculate it? I dont get why people stress using em..

1 Answer

Steven Parker
Steven Parker
229,670 Points

The value of em is that it is relative to the font size of the parent element. So if you want an element to differ from it's parent by a certain percentage increase (or decrease) in font size, using em allows that relative change to be preserved if future changes are made to the parent element.

On the other hand, rem keeps the target element font size the same if and when a change is made to the parent element. So it's basically a design decision — are you choosing a specific size for the element based only on the root document font size, or are you creating a percentage change relative to the parent element?

thanks so much. this makes a lot of sense.