Hello everyone, I am a beginner and I am learning about CSS Box Model.
As far as I have learned, the size of an element using border-box includes the padding, border, and content, which will automatically size to the size of that element. For example, in the CSS code of Davie’s Burgers practice, the .button element has the following CSS code:
.button {
border-radius: 4px;
color: #05A8AA;
display: block;
font-weight: 700;
width: 200px;
padding: 20px;
margin: 40px auto;
border: 1px solid blue;
}
According to my understanding of border-box, the size of all the elements (including padding, border, and content) should be 200px.
However, when checking, it has increased to 242px, similar to content-box.
So what is the difference between them? I hope someone can explain it clearly to me. Thank you very much.