Module 5 · Lesson 1 of 417/60 in the course~18 min
Module lessons (1/4)
The Box Model & box-sizing: border-box
Lesson preview5 hands-on exercises readyModern HTML & CSS · The Box Model, Display & Modern Units
Inspect content, padding, border, and margin dimensions and adopt box-sizing: border-box globally.
What you'll learn in this lesson
- Visualize the four layers of every CSS box: Content, Padding, Border, and Margin.
- Explain why browser default
box-sizing: content-boxadds padding + border on top of declaredwidth. - Apply
*, *::before, *::after { box-sizing: border-box; }universally so layouts stay predictable.
Overview
In CSS, whether an element looks like a round avatar badge, a button, or a newspaper column, the layout engine sees a four-layer rectangle:
Drag width, padding, border, and margin sliders, then flip box-sizing to see inner vs outer dimensions recalculate instantly:
Sections covered in this lesson
- 1Every HTML Element Is a Rectangular Box
- 2Play with the Interactive Box Model Inspector
Pro Lesson · The Box Model, Display & Modern Units
Unlock "The Box Model & box-sizing: border-box" and the full Modern HTML & CSS curriculum
Inspect content, padding, border, and margin dimensions and adopt box-sizing: border-box globally.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.