Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a header touch top of page?

Tags:

html

css

Trying to make a header touch the top of my page, however there seems to be an automatic margin, even if specified otherwise.

I've tried specifying margin-top: 0, and have set margin: 0 to the body as well.

h1 {
  margin-top: 0px;
}

body {
  margin: 0px;
}
  <h1>test</h1>

Instead of touching the top of the page, the "test" header has an automatic margin at its top.

like image 239
Peter Jordanson Avatar asked Nov 07 '22 22:11

Peter Jordanson


1 Answers

adding line-height: 75%; seems to do the trick:

h1 {
  margin-top: 0px;
  line-height: 75%;
}

body {
  margin: 0px;
}
like image 180
Yann Stoneman Avatar answered Nov 15 '22 05:11

Yann Stoneman