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.


Why is there a gap?

I already set margin of header to be "0 auto", but there is still a white line of space between header and section. How come?


This is the code.

header{ text-align:center; background:blue; margin: 0 auto; }

h1,h2{ color:black; }

nav a{ color:#fff; }

section{ background:orange; }

Would need to see the code to find out why. Could you add the code to codepen.io and paste the link in here?

3 Answers

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,705 Points

I got rid of my margins on my website by putting a margin on the universal selector. Failing that, You might be able to sneakily hide it by applying a matching background colour as a temp fix but that depends on your design really,

Jeremy Germenis
Jeremy Germenis
29,854 Points

Extra spacing between elements can be caused by a few things such as line breaks in your markup and margin/padding.

k solved it

we need:

ul,p{ margin:0; }