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

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?

Thanks!

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
MOD
Jonathan Grieve
Treehouse Moderator 91,253 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; }