The Edges

The browser creates a rectangle for each element in the HTML document. The Box Model describes how the padding, border, and margin are added to the content to create this rectangle.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/6023dfbe-f65f-4d8f-94df-30ec43f6a4de/Untitled.png

CSS Box Model

Diagram from CSS2.2 Working Draft

The perimeter of each of the four areas is called an edge. Each edge defines a box.

Example

div {
    border: 5px solid red;
    margin: 50px;
    padding: 20px;
}

This CSS styles all div elements to have a top, right, bottom and left border of 5px in width; a top, right, bottom and left margin of 50px; and a top, right, bottom, and left padding of 20px. Ignoring content, our generated box will look like this:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/43d83abe-2d66-4c6b-be2d-cd96961f8974/Untitled.png

Box Model for Above Example

Screenshot of Google Chrome’s Element Styles panel