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

HTML How to Make a Website Responsive Web Design and Testing Responsive Web Design

Sara Anne
Sara Anne
2,624 Points

I don't quite understand the difference between margin and padding. Can anyone clarify?

I don't quite understand the difference between margin and padding. Can anyone clarify?

3 Answers

Blake Wallace
Blake Wallace
3,864 Points

To go along with the above answer here is a simple way to see the difference. Say you make a border for an element. If you add more padding, the border will move away from your text, img, whatever your element is. If you add margin, you border won't move, however you will notice other elements being pushed further away. As you'll learn on down the road there are times padding is needed and when margin is need. I suggest looking at the css basics course followed by the css layout basics. It will give more examples of margins vs padding and give you more opportunity to use them. Hope I'm making sense. Happy coding!

Yes, there is a picture, simply follow every detail of the picture and you will be fine with it. http://www.avajava.com/tutorials/lessons/how-are-margins-borders-padding-and-content-related.html

Shane Oliver
Shane Oliver
19,977 Points

Margin is outside the element while padding is inside the element