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
hollan
917 PointsIs it best to set margins in em or percentage?
Would em's be better so the spacing would change in relation to the font size? Would it ever make much difference which you used?
3 Answers
Steven Parker
243,898 PointsIf the containing element is not width-constrained, it would make a big difference. Spacing by em's would be relative to the font size, but by percentage would be relative to the window size.
Nadia Masiero
3,468 PointsIf you are using em for other dimensions then use em for the margins and padding as well so that those gaps stay proportional to the text.
The only thing where you have to use px is for a minimum width border.
dman10345
7,109 Pointsem's would be your best bet as it is relative to your font size and thus you can keep proportions correct. It doesn't always make a huge difference however using percentages can cause some funky results sometimes and generally em's are more predictable.