I am beginner to web development and I faced this issue and didn't find good answer. I have two HTML code
<html>
<head>
<style>
#div{
background: red;
height: 100%;
}
h2{
text-align: center;
}
</style>
</head>
<body>
<main>
<section id="div">
<h2>I am Robert</h2>
</section>
<section>
<h1>Hello, this is a test</h1>
<p>Choose your plan</p>
</section>
</main>
</body>
</html>
And this is the second code
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>uHost</title>
<link rel="shortcut icon" href="favicon.png">
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">
<link rel="stylesheet" href="main.css">
<style>
#product-overview {
background: #ff1b68;
height: 100%;
}
</style>
</head>
<body>
<main>
<section id="product-overview">
<h1>Get the freedom you deserve.</h1>
</section>
<section id="plans">
<h1 class="section-title">Choose Your Plan</h1>
<p>Make sure you get the most for your money!</p>
</section>
</main>
</body>
</html>
Now when applying height: 100% to the first code, the result was that section with height: 100% filled the full screen and when applying the same property to the second code, the section didn't fill the full screen. My question is why height: 100% sometimes fill the entire screen and sometimes not?