The box Model

The Box Model represents how the browers sees your content. Accord to the model, Content is on the inside,padding is used to move content away from the edges of the box,margin is used move the box around in space.

Below is a diagram of the box model...

The Box Model Diagram

Examples of the Box Model in Action

example 1: Adding border and padding to a box...

Box 1

example 2: Adding only border/padding to one direction of the box...

Box 2

example 3: Shorthand code for padding/margin on a box...

Box 3

In shorthand code, the first number represents top and bottom. The second number represents left and right.

example 4: Shorthand code for all sides of a box..

Box 4

In shorthandcode, the first number is the top, then right, then bottom, then left. In other words, clockwise.