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) Enhancing the Design With CSS Web Fonts with @font-face

Matthew Rigdon
Matthew Rigdon
8,223 Points

Adding margins in CSS?

Let's say you have both a h1 and an h2 with written information.

<h1>Hello there!</h1>
<h2>It is a wonderful day</h2>

If you wanted to add spacing between these two headings using margins you could add a bottom margin to h1 or add a top margin to h2. They both accomplish the same thing. However, is there a correct or well accepted way to add margins? For example, always use bottom margins?

What do you guys think?

1 Answer

There isn't an accepted default. This is because you don't need to worry about only bottom or top margins, thanks to something called collapsing margins. http://www.sitepoint.com/web-foundations/collapsing-margins/