Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Layout Basics CSS Layout Project Creating and Styling the Layout Containers

Grace kim
Grace kim
499 Points

why h1 is set to margin-top 0 separately but h2 and h3 are given margin-top 0 at the top in base element styles??

Is there any specific reason that the margin-top of h2 and h3 are set to 0 at the top but h1 is not included here. Is there any benefit by setting h1 margin-top to zero later?

1 Answer

Steven Parker
Steven Parker
216,083 Points

At about 1:30 in the video, all of the h1 margins are set to 0 in the ".name" rule, along with the font size. There would be no value in setting just the top margin later, unless you wanted a setting other than 0.

Doing this separately allows only the top margin to be set on the other elements, and also prevents them from being affected by the font size setting.