2

The red #container element doesn't seem to take up all the available space in the document, even when it's width is set to 100%. There seems to be some extra padding in the html element, but even when I set it's padding to 0 it's still there.

How could I fix this? Thanks in advance.

Demo code:

body, html {
  width: 100%;
  height: 100%;
}
#container {
  width: 100%;
  height: 100%;
  background-color: red;
}
<body>
  <div id='container'></div>
</body>

JsFiddle here

MaxiGui
  • 5,806
  • 4
  • 14
  • 32
Daavee18
  • 55
  • 4
  • you only have this margin in most of the "snippet", "fiddle" to the body, on a normal html page, you wont have that. So just add `margin:0;` to your `body` – MaxiGui Jun 02 '22 at 15:26

2 Answers2

0

Try adding margin: 0px; to your CSS:

body,
html {
  width: 100%;
  height: 100%;
  margin: 0px;
}

Seems to be working here:

https://jsfiddle.net/k2boqeLt/

cklimowski
  • 574
  • 5
  • 20
0

You have to add padding: 0 and margin: 0 to:

body, html {
  width: 100%;
  height: 100%;
}
Jorge Guerreiro
  • 451
  • 4
  • 17