The CSS Box Model is one of the most fundamental concepts in web design. It defines how every HTML element is built: content, padding, border, and margin together form the box around the element.
The Box Model consists of four main parts: content, padding, border, and margin. Together these determine the total size and placement of the element.
In the following example, a <div> element is displayed with padding, border, and margin settings:
The following examples illustrate how padding, border, and margin values change the appearance of an element.
By default, width and height only apply to the content, and padding and border are added. With the <box-sizing: border-box;> setting, padding and border are included within the defined dimensions.
Selected: padding (1/4)
div {
width: 200px;
padding: 20px;
padding: 5px solid black;
margin: 10px;
}
Move the slider to set the value, then check your answer.
Proper use of the Box Model is essential for precise layout. The following tips help:
Please sign in to ask Lara about CSS box model.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.