Menu
Coddy logo textTech

What is the Box Model?

Part of the Styling with CSS section of Coddy's HTML journey — lesson 33 of 76.

In CSS, every HTML element is treated as a rectangular box, following the Box Model. This model consists of four main parts:

  1. Content – The actual text, image, or other content inside the box.
  1. Padding – Space between the content and the border. It increases the size of the element but keeps the background color within.
  1. Border – A line that surrounds the padding and content. It can have different styles, colors, and widths.
  1. Margin – Space outside the border that separates the element from other elements.

Understanding the Box Model helps in controlling spacing and layout in web design! 🚀

Cheat sheet

The CSS Box Model treats every HTML element as a rectangular box with four parts:

  1. Content – The actual text, image, or other content inside the box
  2. Padding – Space between the content and the border
  3. Border – A line that surrounds the padding and content
  4. Margin – Space outside the border that separates the element from other elements

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Styling with CSS