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

Difference between margin: 0 0 10px and margin: 0 0 10px 0 ?

Do we always need to definite the top, bottom, left and right properties? Or if you leave out one, does the browser assume it to be 0?

2 Answers

Margin properties work clockwise. Top > Right> Bottom > Left | If you skip a value it groups the previous value together with it's opposite. So 0 0 10px = 0 on the top 0 on the left and right and 10px on the bottom and 0 0 10px 0 is only adding margin to the bottom as well.

There's no difference between those 2. If you only enter 3 numbers, it assumes the second number applies to the left and right. If they're the same, there's no need to enter it.