The CSS box model consists of: Content (where text/images appear), Padding (clears area around content), Border (goes around padding), and Margin (clears area outside border).
CSS Tutorial
CSS Tutorial
CSS Advanced
CSS Responsive Layouts
Advertisement
Google AdSense Slot (LEADERBOARD)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Core Architecture
7 min read
•
Chapter 11 of 23
The CSS Box Model
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.
Total Element Width = Width + Left Padding + Right Padding + Left Border + Right Border + Left Margin + Right Margin
Example
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 280px;
padding: 20px;
border: 5px solid #04aa6d;
margin: 25px;
background: #ecfdf5;
font-family: sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div class="box">Box Model Demonstration</div>
</body>
</html>
Try it Yourself >>
Opens live sandboxed code editor
Advertisement
Google AdSense Slot (IN-ARTICLE)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Community Q&A & Discussion
Verified
No questions yet. Be the first to start the discussion!