As you can see There are no background-color above and below header(My Todo App). But if I just put padding: 1px 0; in header then background-color comes back. Can anyone explain how does it work. This may be silly question or something very basic but I am new to css so its so confusing to understand these simple things. Any answer is apprecited.
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.wrapper {
max-width: 500px;
margin: 30px auto;
background-color: #f9dfdc;
border: 1px solid #0c4271;
overflow: hidden;
}
header {
background-color: #0c4271;
color: #f9dfdc;
}
header h2, header p {
text-align: center;
margin: 10px 0;
}
<div class="wrapper">
<header>
<h2>
My Todo App
</h2>
<p>
Plan your entire day
</p>
</header>
<main class="todo-wrapper">
<form id="add-todo">
<label for="input">What do you want to add ?</label>
<input id="input">
<button type="submit">
Add Task
</button>
</form>
<div class="todo-list">
<ul>
</ul>
</div>
</main>
</div>