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 How to Make a Website Customizing Colors and Fonts Resize Text

What'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

In addition to Ayoub's answer, here is an image showing the differences

CSS Box Model

Thanks man!

Thanks for the diagram ,it really helps.

Tony Brown
Tony Brown
Courses Plus Student 1,678 Points

I 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.

margin : 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

Thanks!