.d1 {
background-color: lightblue;
}
.d2 {
background-color: yellow;
margin-top: 20px;
}
<div class="d1">
<div class="d2">Test</div>
</div>
In this simple example, d1
is the parent element of d2
. But d2
causes both itself and d1
to have a margin-top
of 20px
. Why does it behave this way?