By the end of this lesson, students will understand:
Every element is treated as a box with:
+-------------------------+
| Margin |
| +-------------------+ |
| | Border | |
| | +---------------+ | |
| | | Padding | | |
| | | +-----------+ | | |
| | | | Content | | | |
| | | +-----------+ | | |
| | +---------------+ | |
| +-------------------+ |
+-------------------------+
| Property | Meaning |
|---|---|
margin |
Space outside element |
padding |
Space inside element |
border |
Line around element |
width / height |
Size of content box |
.box {
width: 200px;
padding: 20px;
border: 2px solid black;
margin: 30px;
}
.card {
background: lightblue;
padding: 20px; /* inside */
margin: 30px; /* outside */
}
Take full width
Start on a new line
Examples: div, p, h1, section, table