Margin showing up at top? [Solved]

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.


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.


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

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.

1 Like

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