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 trialDavid Hobbs
5,029 PointsClarification margin: 0 0 10px;
Hello, can you please tell me how the browser will read margin: 0 0 10px;
I know its margin: top right bottom left; but Id like clarification on the above? Thank you.
2 Answers
Jeremy Hayden
1,740 PointsDavid,
Css margin short hand code can be a bit confusing at first.
For the quick answer first, the above code means:
Top margin = 0 Right/Left margin = 0 Bottom margin = 10px or pixels
Why?
Here is a little cheat sheet to help you remember:
margin: 20px;
//All four margins are 20px
margin: 20px 50px;
//Top & Bottom margin = 20px, left & right = 50
margin: 5px 10px 20px;
// top=5, left/right=10, bottom=20
margin: 5px 10px 20px 30px;
// Top=5, Right=10, Bottom=20, Left=30
ferdy
2,484 PointsYou are right in that when you specify all four numbers, they are, top, right, bottom, and left respectively.
However, if you only specify three numbers, they are, top, right/left, and bottom. From your example this means: top 0px right and left 0px bottom 10px.