I'm expecting the vertical gap between bottom border of first div and top border of second div to be 45px in this case but browser collapse bottom and top margin.
Effective gap b/w bottom border of first div and top border of second div in browser display is 25px.
Ideally border should prevent margin collapse. What is the mistake here? I have not applied any positioning or float.
HTML
<body>
<div><p>A</p></div>
<div><p>B</p></div>
</body>
CSS
div{
width:200px;
height:200px;
}
div:nth-child(1){
background-color: #F52C6F;
border-bottom: 10px solid black;
margin-bottom: 20px;
}
div:nth-child(2){
background-color: #0ECCCC;
border-top: 10px solid yellow;
margin-top: 25px;
}