css-box-model-example.html
css-box-model-example.html
5.D.PROGRAM
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Box Model Example</title>
<style>
/* Basic styling for the body */
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f4f4f4;
}
.box {
width: 300px; /* Set width of the content area */
height: 200px; /* Set height of the content area */
background-color: #3498db; /* Blue background for content */
color: white;
font-size: 20px;
text-align: center;
line-height: 200px;
/* Box Model */
padding: 20px; /* Space inside the box between content and border */
border: 5px solid #2c3e50; /* Border around the box */
margin: 30px; /* Space outside the box */
.explanation {
font-size: 18px;
line-height: 1.6;
color: #333;
}
</style>
</head>
<body>
<div class="box">
Content
</div>
<div class="explanation">
<h2>Box Model Breakdown:</h2>
<p><strong>Content:</strong> The actual text or media inside the box. In this
case, it’s the word "Content" inside the blue area.</p>
<p><strong>Padding:</strong> The space between the content and the border. This
area is inside the box and is set to 20px in this example.</p>
<p><strong>Border:</strong> The line surrounding the padding. In this example,
the border is 5px solid and is colored dark gray (#2c3e50).</p>
<p><strong>Margin:</strong> The space outside the box. The margin separates
this box from any other element (or the edges of the screen). Here, it is set to
30px.</p>
</div>
</body>
</html>