Back to Lessons

CSS Box Model Layout

April 5, 2026

Box Model and Dimensions

Every HTML element is a rectangular box.

Box Model Diagram

Content (width x height)
+ Padding (content spacing)
+ Border (visual edge)
+ Margin (outside spacing)
= Total element width

Box Sizing

* {
  box-sizing: border-box;
}

.content {
  width: 300px;
  padding: 20px;
  border: 5px solid;
  margin: 10px;
}

Key Properties

  • width/height/max-width/min-height
  • margin: 10px auto (center block)
  • padding: 20px 10px (vertical horizontal)
  • border-radius: 10px (rounded corners)