Padding vs Margin
Both are spacing. Padding is space inside the box (between the border and the content), and margin is space outside the box (between it and other boxes).
Padding
Space inside the box, between the border and the content.
Margin
Space outside the box, the distance to other boxes.
At a glance
| Padding | Margin | |
|---|---|---|
| Where | Inside the border | Outside the border |
| Background color | Gets colored too | Stays uncolored |
| Think of it as | Bubble wrap inside a box | The gap between boxes |
Use “Padding” when…
- When the text in a button looks cramped
- When card content is pressed right up against the border
- When you want a colored area to be bigger
🤖 Say it to your AI like this
Make the inner spacing (padding) of the buttons 12px top and bottom and 20px left and right. Keep the space between buttons the same.
Use “Margin” when…
- When sections are too close together
- When you want space between cards
- To add space between a heading and the text
🤖 Say it to your AI like this
Increase the outer spacing (margin) between sections to 80px top and bottom. Don't change the spacing inside the sections.
💡 How not to mix them up
If you just say 'add more space', the AI may change either one. Say whether you mean inside (padding) or outside (margin).
More comparisons
Modal vs DrawerModal vs Toast NotificationFrontend vs BackendGit vs GitHubCookies vs CacheFlexbox vs Grid LayoutPagination vs Infinite ScrollTabs vs AccordionDropdown Menu vs SelectCheckbox vs Toggle SwitchSkeleton Loading vs Loading SpinnerBuild vs DeployDomain vs HostingServer vs ServerlessBadge vs Tag / ChipHamburger Menu vs Bottom NavigationCookies vs localStorageTooltip vs Popover
← All comparisons