Box model

noun

say it: “BOKS MOD-ul” /bɑks ˈmɑdəl/

The way CSS treats every element as a box made of four layers: the content, padding around it, a border around that, and margin outside.

What is the box model?

The box model says every element is a box made of four layers: content, then padding, then border, then margin.

.card {
  width: 200px;     /* content */
  padding: 16px;    /* around the content */
  border: 2px solid #333;
  margin: 12px;     /* outside the border */
}

In a sentence

  • “Once I understood the box model, I knew whether to add padding or margin to give the card more room.”

Level: Novice · More CSS terms at this level

Updated