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 (2014) The Box Model Margins

Ryan Cross
Ryan Cross
5,742 Points

em values;

I see how they work but I'm not seeing the advantage over a px value. Why not skip the calculation?

1 Answer

Steven Parker
Steven Parker
231,269 Points

The advantage of em units is the dimensions you set will adapt to the font size. With pixels it will never change.

according to the video there is no absolute value so how does the em and rem value relative to ,steven ?

Steven Parker
Steven Parker
231,269 Points

If I understand your question, rem values are relative to the default font size of the document, and em values are relative to the font size of the parent element.

oh got that , tks u , at first i see no default value , so i don't know which base do rem and em lean on cause every font-size are rem and em

Steven Parker
Steven Parker
231,269 Points

If not explicitly set in the CSS, 1rem will be equal to the default font-size provided by the browser (usually 16px).