Mehmet Mehmet - 25 days ago 8
CSS Question

Remove space between header and the page

My header has a space above it. I want it to stay to the top without any space. I attached an image that shows the space.

enter image description here

Here is my code:



body {
background-color: red;
}
#example {
height: 75px;
background-color: #484848;
}

<header id="example">
example
</header>




Answer

The <body> element has a default margin. Remove it:

body {
  background-color: red;
}
#example {
  height: 75px;
  background-color: #484848;
}
body {
  margin-top: 0;
}
<header id="example">
  example
</header>

Comments