Home › CSS Tutorial › The box model
The box model
Every element is a box: content, padding, border, margin.
Padding is inside the border, margin is outside. box-sizing: border-box makes width include padding and border, which is easier to reason about.
Example code
<style>
div { box-sizing: border-box; width: 240px; padding: 20px;
border: 4px solid navy; margin: 30px; background: #eef; }
</style>
<div>Padding, border and margin in action.</div>