CSS Box Model Example

Content-box (Default)

This is a content-box element.

Width: 300px + 40px (padding) + 10px (border) = 350px

Height: 200px + 40px (padding) + 10px (border) = 250px

Border-box

This is a border-box element.

Width: 300px (including padding and border)

Height: 200px (including padding and border)

Inline vs Block Elements

This is a paragraph with an inline element inside. Inline elements only take up as much width as necessary and allow other elements next to them.

This is a block-level element. It takes up the full width available and creates a new line before and after it.

Box Model Components

The box model consists of: