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 CSS: Cascading Style Sheets Center the Wrapper

What does padding really do?

I want to get a clear conception of this padding property. Thanks in advance.

1 Answer

Padding is the space inside an element, and margin is the space around an element. The border is right between.

Look here:

        margin
--------------------
|      padding     |
|                  |
|      content     |
|                  |
|      padding     | <- Border
--------------------
        margin


           margin
----------------------------
|         padding          |
|                          |
| content of other element |
|                          |
|         padding          | <- Border
----------------------------
           margin

Look at this post for more information.

Also, check out the CSS box model at w3schools.

Finally, I must mention that doodling around with stuff will help you understand how the thing you're using works.

Here's an experiment: try making an h1 element in the HTML and setting it's background color to something different from the background color that the H1 is on. Then, try adding padding. You should see the output pretty clearly. Try different amounts of padding and seeing its output! :smile: