Visual CSS
CSS: Margin vs Padding
By Xah Lee. Date:
2010-03-15
. Last updated:
2026-07-10
.
Difference between margin and padding
margin
padding
Text. Alice in Wonderland.
margin
is the area outside the border.
padding
is the area inside the border.
Border
is between margin and padding.
CSS. box model, margin, padding, border
CSS: Box Model. Index.
CSS: Margin vs Padding
CSS: margin
CSS: padding
CSS: Box Sizing
CSS: Border
CSS: Outline
CSS: Round Corners
CSS: Box Shadow
Web Dev Search 🔍
HTML
CSS
JS
JS Obj Ref
DOM
SVG
CSS
Basics
Basics
Comment Syntax
Length Units
Selectors
Selector
Color
Color
Font
Font
Text Decoration
Text Deco
Margin, Border
Box Model
Layout
Layout
Layers
Position
Animation
2D Transform
Transition
Animation
Line Wrap
white-space Wrap
overflow-wrap
Text Justify
Misc
@media
var()
calc()
Reset
Dark Theme
Misc Index
Misc. Index