The
box-sizing property allows us to include the padding and border in an element's total width and height.
If you set
box-sizing: border-box; on an element, padding and border are included in the width and height:
HTML:-
<div class="div1">Both divs are the same size now!</div>
<br>
<div class="div2">Hooray!</div>
CSS
.div1 {
width: 300px;
height: 100px;
border: 1px solid blue;
box-sizing: border-box;
}
.div2 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
box-sizing: border-box;
}