1

I'm sure the answer is obvious, but I haven't been working with html/css that much...

There is a gap of white space in between the top of the browser and the first div. I don't really get why the gap is there. I didn't use margin-top or padding-top or border-top in the css, so why is there a gap?

Thanks!

Derek
  • 11,980
  • 26
  • 103
  • 162

7 Answers7

10

While it would be extremely helpful if you actually posted some code or a link to the site, I would assume it's just the default padding. Most browsers have default styles for things like body that you may want to clear. Try something like this:

html, body{
   padding: 0;
   margin: 0;
}

If that doesn't fix it you'll need to give more information.

James Montagne
  • 77,516
  • 14
  • 110
  • 130
2

Without seeing anything I'd imagine you either need to clear the default padding on the body element or you have a heading tag in that div that is adding some extra goodness.

Are you using a reset? http://meyerweb.com/eric/tools/css/reset/

Seth
  • 6,240
  • 3
  • 28
  • 44
1

if the page is wrapped with a wrapper, use:

 #wrap{
     margin:0 auto;
     padding:0
 }
bingjie2680
  • 7,643
  • 8
  • 45
  • 72
0

I had the same problem. It was fixed when I added 30px of padding to my div container. I used

   .top-container {
       padding-top: 30px;
    }

My problem happened after I set some images to an absolute position in my div (which had a position of relative.) For some reason that gap appeared, but setting the padding worked for me.

Jac Davis
  • 1
  • 1
0

I know this is 9 years old but... body { margin:0; } type that in between the Tags and it should work

0

Once again, some context would be nice but if these solutions aren't cutting it, then there's a good change your a victim of collapsing margins. Try setting the overflow property of the body to auto

Marlin
  • 751
  • 4
  • 8
0

I had the same problem. Floating the upper divs solved it.

1qazxsw2
  • 2,589
  • 4
  • 20
  • 19