Skip to main content

Tailwind CSS Spacing Scale

Complete Tailwind v4 spacing reference.
Base unit: --spacing: 4px

Complete Scale

p-0
0px
p-0.5
2px
p-1
4px
p-1.5
6px
p-2
8px
p-2.5
10px
p-3
12px
p-3.5
14px
p-4
16px
p-5
20px
p-6
24px
p-7
28px
p-8
32px
p-9
36px
p-10
40px
p-11
44px
p-12
48px
p-14
56px
p-16
64px
p-20
80px
p-24
96px
p-28
112px
p-32
128px
p-36
144px
p-40
160px
p-44
176px
p-48
192px
p-52
208px
p-56
224px
p-60
240px
p-64
256px
p-72
288px
p-80
320px
p-96
384px
p-px
1px

Spacing Utilities

Padding

p-*All sides
px-*Horizontal (left & right)
py-*Vertical (top & bottom)
pt-* pr-* pb-* pl-*Individual
ps-* pe-*Logical (start/end)

Margin

m-*All sides
mx-*Horizontal (left & right)
my-*Vertical (top & bottom)
mt-* mr-* mb-* ml-*Individual
ms-* me-*Logical (start/end)

Usage Examples

Card Padding

<div class="p-4 md:p-6 lg:p-8">
  <!-- 16px → 24px → 32px -->
</div>

Button Spacing

<button class="px-4 py-2">
  <!-- 16px horizontal, 8px vertical -->
</button>

Stack Spacing

<div class="space-y-4">
  <!-- 16px gap between children -->
</div>

Grid Gap

<div class="grid gap-6">
  <!-- 24px gap between items -->
</div>

About Tailwind Spacing

Tailwind v4 uses a simple formula: calc(var(--spacing) * n) where --spacing: 4px by default.

So p-4 = 4 × 4px = 16px, and m-8 = 8 × 4px = 32px.

For arbitrary values, use bracket notation: p-[17px] or m-[2.5rem]