What is the CSS Box Model?

The box model in CSS is a container that contains various properties, including borders, margins, padding, and the content itself. These properties collectively determine the dimensions and spacing of an element.

Let’s break down the key components:

  • Content: The actual data in text, images, or other media forms can be sized using the width and height property.
  • Padding: Padding is used to create space around the element, inside any defined border.
  • Border: The border is used to cover the content & any padding, & also allows setting the style, color, and width of the border.
  • Margin: Margin is used to create space around the element ie., around the border area.

1. Content Area

  • Contains the actual data, such as text, images, or other media.
  • Sized using the width and height properties.
  • Bounded by the content edge.

2. Padding Area

  • Surrounds the content area.
  • Space within the border box.
  • Dimensions are determined by the width and height of the padding box.

3. Border Area

  • Lies between the padding and margin.
  • Width and height are defined by the border.

4. Margin Area

  • Separates the element from adjacent elements.
  • Dimensions specified by the margin-box width and height.


The following figure illustrates the Box model in CSS.

CSS Box model

CSS Box Model is a Fundamental concept in CSS that governs how elements are structured and positioned on a webpage. By learning this model, you’ll create elements visually appealing that adjust seamlessly to various screen sizes. It is used to create the design and layout of web pages.

In this article, we’ll learn the key components of the box model and its practical implications.

Similar Reads

What is the CSS Box Model?

The box model in CSS is a container that contains various properties, including borders, margins, padding, and the content itself. These properties collectively determine the dimensions and spacing of an element....

How Does the Box Model Work?

When setting the width and height properties for an element, we’re mainly adjusting the content area. However, to calculate the full size of the element, we need to consider padding and borders also....

Examples of Box models in CSS

Now, We have learned the working of the CSS Box Model in-depth and now we will see Box Model examples so that we can properly understand it....

Contact Us