0

I am having a problem with a gap between the div "name" and the top of the screen. I've done some research and all I can find is margin which I have already set and position: absolute; that messes up with the position of the div.The gap wasn't here earlier and I don't know what I did to make it appear.

Here's my code:

body {
  background-image: url("./console.png");
  background-size: cover;
  margin: 0;
  padding: 0;
}

.name {
  font-size: 50px;
  font-family: Brush Script MT;
  text-align: center;
  color: white;
  background-color: black;
}
<div class="name">
  <h1> Clovis Sargenton Callard </h1>
</div>
AK47
  • 8,646
  • 6
  • 37
  • 61

2 Answers2

1

This is caused by collapsing margins

Remove the top margin on your h1 to create the effect you want.

body {
  background-image: url("./console.png");
  background-size: cover;
  margin: 0;
  padding: 0;
}

.name {
  font-size: 50px;
  font-family: Brush Script MT;
  text-align: center;
  color: white;
  background-color: black;
}

h1 {
  margin-top: 0;
}
<div class="name">
  <h1> Clovis Sargenton Callard </h1>
</div>
sol
  • 20,947
  • 5
  • 36
  • 56
0

Set margin: 0 on your h1 element.

body {
  background-image: url("./console.png");
  background-size: cover;
  margin: 0;
  padding: 0;
}

.name {
  font-size: 50px;
  font-family: Brush Script MT;
  text-align: center;
  color: white;
  background-color: black;
}

h1 {
  margin:0;
}
<div class="name">
  <h1> Clovis Sargenton Callard </h1>
</div>
Julio Feferman
  • 2,598
  • 3
  • 14
  • 26