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

Did not understand padding properly, help please?

Hi, I have a few questions regarding padding.

Does padding just fill space up with the <div> element's contents around the 4 edges in general, in every case?

Or does padding offset space in the interior of the browser's view, from the outer 4 edges of the browser area?

Does it expand the space/stretch out the edges of HTML elements from its 4 sides or does it work from outside-in, meaning adding space from the 4 corners of the browser window thereby shrinking everything inside the browser (like squashing its size down)?

Is padding like stuffing up the space up with cushions in order to fill up space or padding as in soften the effect of a hard surface by padding it with stuff?

Can't visualize how it works clearly. Thanks again. :)

2 Answers

Check this post.

Look here for an example of any element:

               margin
          -----------------
         |                |           
         |     padding    |            
         |                |           
margin   |     content    |     margin
         |                |                 
         |     padding    |            
         |                |          
          -----------------
                margin

I hope this helps. ~Alex

Here is an example image to help explain - click here

This will show you the comparison between the content, padding, borders, and margins. Hope this helps!