0

I have this simple code:

body {
    padding: 0;
    background-color: red;
    margin: 0;
}

header {
    background-color: blue;
    text-align: center;
  }
<body>
    <header>
        <h2>Vendi su eBay e guadagna extra cash!</h2>
    </header>
</body>

The problem is that the header is still not at the top of the page and every solution I found isn't working, what's wrong?

here is a screenshot

BTSM
  • 1,585
  • 8
  • 12
  • 26
newbie
  • 15
  • 2
  • 7

2 Answers2

1

It's because margin of h2.

body {
    padding: 0;
    background-color: red;
    margin: 0;
}

header {
    background-color: blue;
    display:flex;
    justify-content: center;
    
}
<body>
    <header>
        <h2>Vendi su eBay e guadagna extra cash!</h2>
    </header>
</body>
BTSM
  • 1,585
  • 8
  • 12
  • 26
0
h2 {
 margin: 0;
}

h2 tag has the default margin so just make it 0.

Joji
  • 356
  • 2
  • 16