CSS Box Model

It is nothing but a term used to represent an element with it's properties. According to the CSS box model, a browser engine represents every element as a box. The content, padding, margins and borders, all together represents a box that wraps around every html element.

Parts of Box Model

Value Description
Content The content of the box, where text and images appear
Padding Clears an area around the content. The padding is transparent
Border A border that goes around the padding and content
Margin Clears an area outside the border. The margin is transparent

<!DOCTYPE html>
<html lang="en">
<head>
<title> CSS Box Model </title>
<meta charset="UTF-8">
<style>
div {
background-color: #e3fdcb;
width: 300px;
border: 10px solid seagreen;
padding: 25px;
margin: 25px;
}
</style>
</head>
<body>
<h2>Demonstrating the Box Model</h2>
<p>The CSS box model is essentially a box that wraps around every HTML element.
It consists of: borders, padding, margins, and the actual content.</p>
<div>This text is the actual content of the box. We have added a 25px padding,
25px margin and a 25px green border. </div>
</body>
</html>

Output

CSS Box Model
This text is the actual content of the box. We have added a 25px padding, 25px margin and a 25px green border. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.




Color Picker

List of color names supported by all browser »



Character Code

List of character codes to display special character »



Language Code

List of all language supported by all browser »



Country Code

List of Country code supported by all browser »

Latest Updates

PHP Introduction

How to Run a PHP program in Xampp?

How can I create a phpinfo.php page?

How to Define a Variable in PHP

PHP Echo and Print Statements

Working with PHP Operators

Understanding the PHP Data Types

How to Write Comments in PHP

How to Define a Constant in PHP

PHP if...else...elseif Statements