dimanche 24 mai 2020

Why my background-color only appear when I put the "body" and "html" in my CSS code? [duplicate]

More details: The background doesn't appear when I remove the html, why it did this? I just want the background-color

To influence the body, but it doesn't appear if I don't put the html and the body in the CSS code.

Someone told me that wasn't necessary to put the html with the body, but when I removed the html, my background disappeared.

body,html (this one)
    height: 50%;
    margin: 0;
  }

  .bg {
    /* The image used */
    background-color:red;

    /* Full height */
    height: 100%; 

    /* Center and scale the image nicely */
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }
  /* background only appear when i put "html" after "body", why ? */
<!DOCTYPE html>
<html>
<head>
    <meta  charset="UTF-8">
<meta name="landing" content="landing page">
<meta  name="Toufik Toudert" content="author"> 
<meta name="keywords" content="HTML,CSS">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="landing page.css" rel="stylesheet" type="text/css">
</head>

<body>
    <div class="bg"></div>
  <p>Welcome in The lab</p>

</body>
</html>
<!---html code-->



Aucun commentaire:

Enregistrer un commentaire