skip to Main Content

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

2

Answers


  1. h2 {
     margin: 0;
    }
    

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

    Login or Signup to reply.
  2. 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>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search