Remember these 3 points:
- The Margin is the extra space around the control.
- The Padding is extra space inside the control.
- The Padding of an outer control is the Margin of an inner control.
Demo Image:(where red box is desire control)
When to use margin vs padding in CSS [closed]
Explanation of the different parts:
- 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
-
Live example (play around by changing the values):