CSS
June 3, 2026 1 min read

CSS Padding and Margin: Understanding Spacing and Layout in Web Design

HS
HEMANT SINGH
Technical Writer & Educator

Padding

Space around element content or space between border and content.

paddingShorthand to apply padding from more than one side
padding-topContent space from top
padding-bottomContent space from bottom
padding-leftContent space from left
padding-rightContent space from right

Margin

Space around an element, or space between two element.

marginSpace from all sides
margin-topSpace from top side
margin-bottomSpace from bottom side
margin-leftSpace from left side
margin-rightSpace from right side