Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Normalize.css top header gap

Tags:

html

css

I'm starting a new project and i wanna use normalize.css but i'm facing one little problem with. In the top of the DOM you'll find a yellow gap, body background-color. The main container is green colored and contains exactly the html from normalize.css demo.

You'll find a demo right here: http://goo.gl/hf8cv

like image 357
birkof Avatar asked Sep 10 '11 20:09

birkof


1 Answers

What you see is margin collapsing.

When an element with a margin is inside an element without border or padding, the margin collapses with the margin of the parent element.

It's the margin of the h1 element that you see at the top. As none of the parents have border or padding, the margin collapses all the way out to the outermost container.

like image 91
Guffa Avatar answered Sep 23 '22 01:09

Guffa