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.