Category
Description
Content
This is the innermost part of the box, which holds the actual content of the element, such as text, images, or other media.
Padding
The padding is the space between the content and the border of the element.
Border
The border surrounds the padding and content and is a visible line that separates the element from its surroundings.
Margin
The margin is the space outside the border and provides separation between the element and other elements on the page.
.box {
width: 200px;
height: 100px;
background-color: #3498db;
padding: 20px;
margin: 10px;
border: 2px solid #2c3e50;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* Apply some styles to the box */
.box {
width: 200px;
height: 100px;
background-color: #3498db;
padding: 20px;
margin: 10px;
border: 2px solid #2c3e50;
}
</style>
<title>Box Model Example</title>
</head>
<body>
<!-- Create a box element with some content -->
<div class="box">
<h2>Box Model Example</h2>
<p>This is a simple example demonstrating the CSS box model.</p>
</div>
</body>
</html>