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 CSS Basics (2014) The Box Model Margins

Padding instead of Margin

Can't we use padding for creating some space instead of margin in h2 and h3.

1 Answer

Sure you can.

But imagine that the h2 and h3 have borders around them. Lets say 5px would be more than enough.

And now imagine you want to give them a little more space between them.

If you add padding to the elements the borders will still stick together. But by giving them a margin property you separate them from each other.

With padding you expand/decrease the space between the h2 or h3 element to the border. With margin you expand/decrease the space between the h2 or h3 element to the next element in the document flow.

LINK here the bo model is explained and presented.

Hope this helps.