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

Rainbow Lin
Rainbow Lin
1,669 Points

How come it is 26px/53px why not 26px/16px for the bottom margin?

since he initially used 53px/16px to calculate 3.3125em. why not the same for the bottom margin?

2 Answers

Answer is quoted : Matteo Simeone 6,211 about 2 months ago :

1 em is equal to the font size of the element to which is applied. If em units are declared on child elements in which a font-size property isn't defined, they'll inherit their font-size value from their parent. This is why in this example the margin-bottom property em unit is relative to h3 font size, while the h3 font-size property em unit is relative to the body font size

sankyeat kumar
sankyeat kumar
5,468 Points

Is it not less complicated to then use an absolute unit for font-size and margins? This way we could avoid the confusion surrounding which numbers to use when. Why are relative units given more of a preference; for a responsive design?

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

I'd have to look at the code carefully to be sure but I think it depends on what the element context is for each element. So the context px value would be the width of the parent element.