box model

[check: โ€ฆ]
๐Ÿ“– Full guide โ†’ ๐Ÿ“– BOX_MODEL.md  ยท  ๐Ÿ“„ Source code โ†’ ๐Ÿ“„ box_model.js โ€” the narrative guide + the computable core. This page is the interactive companion.

The four edges (content-box, default)

margin 10
border 5
padding 20
content
200px
edgewidth
contentโ€”
padding-edgeโ€”
border-edge (offsetWidth)โ€”
margin-edgeโ€”

The demo .c is width:200; box-sizing:content-box โ€” so it expands to 250px at the border edge.

The toggle: content-box vs border-box

Click to flip box-sizing on the gold element and watch offsetWidth.

margin 10
width:200 โ€” click me

offsetWidth = โ€”

content-box โ†’ 250 ยท border-box โ†’ 200.
Same declared width:200.