The Effect of Border on Element Expansion in CSS
The border also expands the block. Let's look at a similar example. Let's give the second block a border of 10px:
<div id="elem1"></div>
<div id="elem2"></div>
#elem1 {
width: 100px;
height: 100px;
background: #f1f1f1;
margin-bottom: 20px;
}
#elem2 {
width: 100px;
height: 100px;
background: #f1f1f1;
border: 10px solid green; /* set the boundary */
}
: