Tailwind Spacing Reference
Complete reference for Tailwind CSS spacing utilities — compatible with Tailwind CSS v3 & v4
Showing 0 utilities
| Class | PX | REM | Visual |
|---|
Quick Converter
What is the Tailwind Spacing Scale?
A Tailwind spacing reference is a lookup table for the spacing utilities that control padding, margin, gap, and the space between child elements. Tailwind does not use arbitrary pixel values for these utilities; it uses a fixed numeric scale, and this page lets you search that scale and convert between class names, pixels, and rem values.
The scale runs from 0 up to 96 in the steps Tailwind ships: 0, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, and 96. Each number maps to a pixel value at four pixels per unit, so p-4 is 16px and p-96 is 384px. Because the root font size is 16px by default, the same value in rem is the pixel value divided by 16, so 16px is 1rem and 96px is 6rem.
The reference covers the padding prefixes (p-, px-, py-, pt-, pr-, pb-, pl-), the margin prefixes (m-, mx-, my-, mt-, mr-, mb-, ml-) plus their negative variants, the gap prefixes (gap-, gap-x-, gap-y-), and the space-between utilities (space-x-, space-y-). Category and type filters narrow the table to one family or one side, and the search box finds a class instantly.
Two converters sit below the table. The first turns a class name such as p-4 into its pixel and rem values, and the second takes a pixel value and returns the nearest Tailwind class. Everything runs in your browser, so no values are sent anywhere.
Key Concepts
- Spacing scale — the fixed set of numeric steps Tailwind uses for spacing utilities.
- Unit rule — each scale step equals four pixels times the number, so 0.5 maps to 2px.
- Rem conversion — pixels divided by the 16px default root size, so 16px equals 1rem.
- Prefix families — padding, margin, gap, and space-between utilities each use their own prefix.
- Negative margins — margin utilities also exist with a leading minus, such as
-mt-4. - Converters — a class-to-pixels/rem converter and a pixels-to-nearest-class converter.
How to Use
- Search for a class — type a class or a numeric value into the search box to find matching spacing utilities.
- Filter by category and type — use the category filter for padding, margin, gap, or space, and the type filter for all sides, x, y, t, r, b, or l.
- Switch the view — toggle between table and list view depending on how you prefer to scan values.
- Convert a class to pixels — enter a class such as
p-4in the first converter to see its pixel and rem values. - Convert pixels to a class — enter a pixel value such as
32in the second converter to find the nearest Tailwind class.
Spacing Scale Reference
| Scale value | Pixels | Rem | Padding example |
|---|---|---|---|
| 0 | 0px | 0rem | p-0 |
| 0.5 | 2px | 0.125rem | p-0.5 |
| 1 | 4px | 0.25rem | p-1 |
| 2 | 8px | 0.5rem | p-2 |
| 3 | 12px | 0.75rem | p-3 |
| 4 | 16px | 1rem | p-4 |
| 5 | 20px | 1.25rem | p-5 |
| 6 | 24px | 1.5rem | p-6 |
| 7 | 28px | 1.75rem | p-7 |
| 8 | 32px | 2rem | p-8 |
| 9 | 36px | 2.25rem | p-9 |
| 10 | 40px | 2.5rem | p-10 |
| 11 | 44px | 2.75rem | p-11 |
| 12 | 48px | 3rem | p-12 |
| 14 | 56px | 3.5rem | p-14 |
| 16 | 64px | 4rem | p-16 |
| 20 | 80px | 5rem | p-20 |
| 24 | 96px | 6rem | p-24 |
| 28 | 112px | 7rem | p-28 |
| 32 | 128px | 8rem | p-32 |
| 36 | 144px | 9rem | p-36 |
| 40 | 160px | 10rem | p-40 |
| 44 | 176px | 11rem | p-44 |
| 48 | 192px | 12rem | p-48 |
| 52 | 208px | 13rem | p-52 |
| 56 | 224px | 14rem | p-56 |
| 60 | 240px | 15rem | p-60 |
| 64 | 256px | 16rem | p-64 |
| 72 | 288px | 18rem | p-72 |
| 80 | 320px | 20rem | p-80 |
| 96 | 384px | 24rem | p-96 |
| Prefix family | Classes | What it controls |
|---|---|---|
| Padding | p-, px-, py-, pt-, pr-, pb-, pl- | Space inside an element. |
| Margin | m-, mx-, my-, mt-, mr-, mb-, ml- | Space outside an element, with negative variants such as -mt-4. |
| Gap | gap-, gap-x-, gap-y- | Space between flex or grid items. |
| Space between | space-x-, space-y- | Margin applied between direct children. |
Worked Examples
- p-4 — padding on all sides equals 16px, which is 1rem.
- px-6 — horizontal padding equals 24px, which is 1.5rem on each side.
- mt-8 — top margin equals 32px, which is 2rem.
- gap-2 — a 8px gap between flex or grid items, which is 0.5rem.
- -mt-4 — a negative top margin of -16px, which is -1rem, used to pull an element upward.
- space-y-3 — 12px of vertical space between children, which is 0.75rem.
Tips and Common Mistakes
- Remember the four pixel rule — multiply the scale number by four to get pixels, so the value is easy to estimate in your head.
- Prefer scale values over arbitrary pixels — sticking to the scale keeps spacing consistent across a project.
- Use gap for flex and grid — gap avoids the extra outer spacing that margins can add to the first and last items.
- Reach for negative margins carefully — negative values pull elements together or create overlap, which is easy to overuse.
- Expect rem to scale — rem-based spacing changes with the root font size, which can shift layouts in unexpected ways.
- Filter before scanning — the category and type filters cut a long table down to exactly the family you need.
Common Use Cases
Spacing is one of the most frequently edited parts of any Tailwind layout, and a quick reference saves a lot of trial and error. These are some of the situations where it helps most.
- Pixel perfect spacing — translate a design value such as 24px into the class p-6 without guessing.
- Design handoff — convert measurements from a design tool into Tailwind spacing classes.
- Responsive layouts — choose consistent spacing steps for each breakpoint of a layout.
- Quick conversion — turn an existing class such as gap-3 into pixels when debugging a layout.
- Overlap and offsets — use negative margins to pull elements together or create deliberate overlap.
- Learning the scale — memorize the common steps faster by seeing class, pixel, and rem side by side.
Frequently Asked Questions
How is the Tailwind spacing scale calculated?
Each scale step equals four pixels multiplied by the number, so p-4 is 16px and p-96 is 384px.
What does the 0.5 step map to?
The 0.5 step maps to 2px, which is 0.125rem at the default 16px root font size.
How do I convert pixels to rem?
Divide the pixel value by 16. For example, 24px is 1.5rem and 32px is 2rem.
Does the reference include negative margins?
Yes. The margin family includes negative variants such as -mt-4, -mx-2, and -mb-8 in addition to the positive classes.
What is the difference between gap and space-x or space-y?
Gap applies to flex and grid containers to space their items, while space-x and space-y add margin between direct children.
Does this cover arbitrary values such as p-[13px]?
This reference covers the default numeric scale. Tailwind itself also supports arbitrary values in square brackets, which are outside this table.
Is the scale the same in Tailwind v3 and v4?
The default spacing scale for these utilities is shared between Tailwind v3 and v4, so the class names and values match.
Is my data sent anywhere?
No. The reference and both converters run entirely in your browser, and nothing is uploaded or stored.