CSS Box Model
The CSS box model

In web development, the CSS box model refers to the composition of a webpage or HTML page from blocks or boxes using CSS. Specifically, the box model describes how the size of each such block and its content is determined through styling instructions. The guidelines of the box model are described by the World Wide Web Consortium (W3C).


The difference in how width is interpreted between the W3C and Internet Explorer box models

The content of each box is determined by four parameters:

  • the height/width describes the dimensions of the actual content of the box (text, images, ...)
  • the padding describes the space between this content and the border of the box
  • the border is any kind of line (solid, dotted, dashed...) surrounding the box, if present
  • the margin is the space around the border

The total width of a box is therefore the width of the content, plus (left- and right-) padding, plus (left- and right-) border, plus (left- and right-) margin. Similarly, the total height of a box equals the height of the content, plus (top- and bottom-) padding, plus (top- and bottom-) border, plus (top- and bottom-) margin.

For example, the following CSS code

.myClass {
  width: 200px;
  height: 100px;
  padding: 10px;
  border: solid 10px black;
  margin: 10px;

will specify the box dimensions of each block belonging to 'myClass'. Moreover, each such box will have total height 160px and width 260px, which is the sum of the content, padding, border and margin.


While the W3C recommendations specify the box model in a clear and unambiguous way, some older browsers do not apply it correctly. Therefore, they may not display the box dimensions of a web page correctly. The most notable bug in correctly applying the box model occurs in older versions of Internet Explorer, and is known as the Internet Explorer box model bug.


  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at defaultlogic.com. Create an account using LinkedIn to manage and organize your omni-channel knowledge. defaultlogic.com is like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us