Web - Margin and Padding
Code Life
By Pierre Marsaa
Introduction to the Box Model
Before we dive into margin and padding, we need to understand the CSS Box Model. In CSS, every element is treated as a box with four areas:
1.
Content: The actual content of the element (text, images, etc.)
2.
Padding: Space between the content and the border
3.
Border: The line around the padding (which we learned about in the previous lesson)
4.
Margin: Space outside the border, between this element and other elements
The CSS Box Model - source
Think of it like a package you get from Amazon:
- The content is the item inside the box
- The padding is the bubble wrap around the item
- The border is the box itself
- The margin is the space you leave around the box when you put it on a table
Verify