1

My div is not being fully 100% as there is still a margin to it

output:

enter image description here

at the top there is still some whitespace

CSS code:

.topbar {
    width: 100%;
    height: 10%;
    background-color: black;
}

thanks!

M123
  • 1,203
  • 4
  • 14
  • 31
Neev Jewalkar
  • 45
  • 1
  • 5
  • Do you use a css reset? Some browser has default margins for body for example – Sfili_81 Sep 20 '21 at 12:09
  • 2
    Does this answer your question? [Why doesn't height: 100% work to expand divs to the screen height?](https://stackoverflow.com/questions/7049875/why-doesnt-height-100-work-to-expand-divs-to-the-screen-height) – Roy Sep 20 '21 at 12:10
  • 2
    You need to reset , try this: `* { margin: 0; padding: 0; }` – Gosi Sep 20 '21 at 12:10
  • Add `html {height: 100%;}` to body and `{margin:0; padding:0;}` to Element – Hadi Hoteit Sep 20 '21 at 12:16

2 Answers2

3

You have a margin at your body probably.

Body comes with a default margin. Try this.

body {
  margin: 0;
}

If this not work for you, try to set margin: 0 to your other elements to find which one causing this.

Also you can use developer tools and see where comes from this margin.

Muhammedogz
  • 774
  • 8
  • 21
1
html, body{
padding: 0;
margin: 0;
}

This may help you .

Nishant Bhosale
  • 251
  • 1
  • 12