Home Tech Blog Human Skills

CSS Concepts:

What's the difference between Border, Margin, and Padding?

27/02/2025

All of these are CSS properties and have a purpose but what do they do? Well I've spent an hour researching this topic, creating visual examples and have come to an understanding.

Lets imagine a house like this:

House Example (all images were taken/made by me.)

The house would be the content, the plot surrounding the house is the Padding.
(The padding is shown in yellow below)

Padding Example Image

The fence surrounding the house/padding would be the border.
(I removed the yellow to make it easier to see)

Border Example Image

But you maybe wondering what about the Margin? Well the Margin would be any space between the house's fence and the neighbor's fence.
(Shown below in red)

Margin Example Image 1
Margin Example Image 2

To summarise my very basic explaination:

Hopefully this article helps give you an understanding of the difference between the 3 properties and how you'd use them.
If you feel like it's not a good enough explaination, feel free to inquire or send me feedback.😁

The End.