CSSCSS · Lesson 05

The Box Model

content, padding, border, margin and box-sizing.

Video tutorialTrack course · freeCodeCamp
Speed
Next lesson
Watch 00:00 · 1 checkpoints Watch on YouTube More on this topic
Transcript & captions
5/5

Every element is a box: content, then padding, then border, then margin. By default width only covers the content, which makes layouts hard to predict — set box-sizing: border-box.

csscss
*, *::before, *::after { box-sizing: border-box; }
Try it yourself

Knowledge check

0/1 answered

With box-sizing: border-box, width includes…