CSS Box Model Interactive Exercise

Instructions

Use the sliders to adjust the content, padding, border, and margin properties of the box. Watch how the box model changes in real-time!

The colored layers represent the different parts of the CSS box model:

100px
100px
20px
5px
20px
Margin
Border
Padding
Content Box
.my-element {
  width: 100px;
  height: 100px;
  padding: 20px;
  border: 5px solid black;
  margin: 20px;
}