I am trying to learn CSS basics. Below is the HTML and CSS for which I am unable to understand something
* {
box-sizing: border-box;
}
body {
font-family: 'Montserrat', sans-serif;
margin: 0;
}
.section-title {
color: #2ddf5c;
}
main {
background-color: burlywood;
}
#product-overview {
background: #ff1b68;
width: 100%;
height: 528px;
padding: 10px;
}
.main-header {
background: #2ddf5c;
padding: 0px 16px;
}
<header class="main-header">
<div>
<a href="index.html">
uhost
</a>
</div>
<nav class="main-nav">
<ul class="main-nav__items">
<li class="main-nav__item"><a href="#">Packages</a></li>
<li class="main-nav__item"><a href="#">Customers</a></li>
<li class="main-nav__item"><a href="#">Start hosting</a></li>
</ul>
</nav>
</header>
<main>
<section id="product-overview">
<h1>Get the freedom you deserve</h1>
</section>
<section id="plans">
<h1>Choose your plan</h1>
</section>
</main>
We can see that there is a small gap between red and green area. As per my understanding, this gap exists because both nav and main are block elements.
Right now, height of header element is 90px(approx.) But if I am trying to update padding of main-header, then browser is removing blank area between header and main elements, and also updating the height of header to 106px
.main-header {
background: #2ddf5c;
padding: 1px 16px;
}
Please help me understand why this is happening.