Back to CSS

CSS Tutorial

Box Model

Understand content, padding, border, and margin.

Every HTML element is treated like a rectangular box.

The box model helps you control spacing inside and outside elements.

css
.box {
  width: 300px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  margin: 24px;
}