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 Layout Basics Getting Started with CSS Layout Why Vertical Margins Collapse

vertical margin preference?

Is putting the h1 element to margin-top to zero preferred over the second method. Second method just seems like a lot of steps.

2 Answers

Eric Butler, i guess it is just preference but i think the first styling was better and less steps.

The second method is doing more than just setting the h1's top margin to 0. If you watch the video again, you can see that the results are not the same. He set h1's margin-top to 0, but then he added 1em of top and bottom padding to the header area, which moved the h1's text down inside the header area so it wasn't so close to its top edge.

Just reviewed the video again.....I do see that the second method he used the padding-top and padding-bottom to overlap the space at the top which was creating a space between the margin and the h1 tag a the top. Then he took the class="name" that is associated with the h1 and placed the margin to zero that way.

Not too many more steps, so is this just a preference between the two?

Yes, seems like just some extra styling to make it look a little better.