The CSS Box Model

Every HTML element can be thought of as a box. The CSS box model defines the size and properties of these boxes. The box model is made up of four parts: margin, border, padding, and the content area.

Box Model Components

Example: Understanding the Box Model

This is a box with:

Comparing Different Box Properties

Larger Border (10px solid blue)
Increased Padding (30px)
Increased Margin (40px)

Notice how changing the margin, padding, or border size affects the total size and spacing of each box. Use these properties to control the layout and spacing of your elements.

Next: Style Tags vs External Stylesheets Back to Table of Contents