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 Positioning Page Content Fixed Positioning

Milo Wyner
Milo Wyner
8,780 Points

What are the reasons for giving the body a padding-top of 68px instead of say, giving the banner a top margin of 68px?

While following along in the video, I noticed that the header overlaps the banner at the top, and I thought to separate it by giving the banner a margin-top of 68px. In the video he gives the body a padding-top instead, which makes sense, but I'm wondering why he did it.

4 Answers

I agree with our colleauge Miroslav. It's just another solution that you can use, it depends on you. Personal choice. However, i'd suggest you, if you don't know yet, to learn and understand difference between margin and padding. Here's a picture that might help you: http://i.stack.imgur.com/D9nU6.gif

Regards! :)

Miroslav Kovac
Miroslav Kovac
11,454 Points

I think here is no some specific reason. Using a maring-top is also one another option how to solve top navigation bar.

Milo Wyner
Milo Wyner
8,780 Points

Thank you for the responses. I kind of figured out why he did it after I experimented with different methods of separating the banner from the fixed header. I think he chose his method because if you use a margin on the banner it moves the body down. It makes more sense to add padding to the body, making the header seem like part of the body when inspecting the layout with a developer tool. But this is all preference, obviously.

David Finney
David Finney
4,116 Points

Thanks for the discussion here, I had the same question!