Delete space above navigation bar

How to remove the space above this navigation bar that I created?

http://gyazo.com/b41271cad8d41c08c52ff26b1f1cab9e

I have a StackOveflow search for this answer, but I cannot find one that seems to fix my problem. I set html, body padding / margin to 0, and also reset all other elements. Does anyone have any advice?

<nav id="header">
  <div class="home-header">
    <a href="#"><h1> testing this </h1></a>
  </div>
</nav>

Here is CSS

#header {
  position: relative;
  margin: 0 auto 0;
  padding-top: 0px;
  background-color: $main-color;
}
+4
source share
2 answers

Live demo

The space at the top is created h1due to its default margin. To fix this:

#header h1{
    margin:0px;
}

PS: I assume that you removed the field for the body tag. If not here, how do you delete it:

body{
    margin:0;
}
+4
source

#header {
  position: relative;
  margin: 0;
  padding-top: 0px;
  background-color: $main-color;
}
body{
margin:0px;
}
<body>
<nav id="header">
  <div class="home-header">
    <a href="#"><h1> testing this </h1></a>
  </div>
</nav>
</body>
Run codeHide result

body margin:0px; margin:0px;

0

Source: https://habr.com/ru/post/1543615/


All Articles