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 trialhamadsharif
1,232 PointsWhat's the difference between a margin and a padding?
I am not stuck or anything like that i just want to understand the difference between a margin and a padding?
2 Answers
Robert Richey
Courses Plus Student 16,352 PointsIn addition to Ayoub's answer, here is an image showing the differences
Ayoub AIT IKEN
12,314 Pointsmargin : is moving the box away from what surrender it ! the space is applied OUTSIDE the box
padding : is moving the content of the box away from its borders ! the space is applied INSIDE the box
hamadsharif
1,232 PointsThanks!
hamadsharif
1,232 Pointshamadsharif
1,232 PointsThanks man!
Kelly Clark
4,387 PointsKelly Clark
4,387 PointsThanks for the diagram ,it really helps.
Tony Brown
Courses Plus Student 1,678 PointsTony Brown
Courses Plus Student 1,678 PointsI understand the difference between the margin and padding, and why it would be used as in the image you provided, Robert. But, can you explain to me why we use MARGIN, PADDING, and LINE-HEIGHT when we have no border? This seems like overkill.