.box {
box-sizing: border-box;
width: 200px;
padding: 20px;
border: 5px solid;
}
150px
150px is right. border-box makes width include the padding and the border. So the box stays 200px wide, and the content gets 200 − 40 − 10 = 150px.
200px is the tempting wrong answer. That is the whole box, not the content. This predictable sizing is why many CSS resets apply box-sizing: border-box to every element.
Read more
- box-sizing (MDN) (https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing)developer.mozilla.org