Margin showing up at top? [Solved]

Margin showing up at top? [Solved]
0

#1

I am working on my portfolio page and as soon as I put an h1 inside two nested divs a white margin/padding shows up at the top of the page and I am not sure why.

Any help would be appreciated.

-Tim


#2

Header elements have a margin around it to separate it from surrounding elements(text, images, etc). When you add it to your project like you have, it appears to push the main part of the page down. You could do 2 things, You could make the body the same color as that section or remove the top margin from the h1 tag in that section.


#3

Hi,

Set your margin to “0” for <h1> tag to remove its default interpretation by the browser.


#4

I like to put:

* {
margin: 0;
padding: 0;
}

as the first thing in my css file. That way I know I won’t have any troubles with default paddings/margins later on.


#5

Thanks for all the tips guys. I now understand what was going on a little better.

-Tim