Spacing

Margin, padding, and gap utilities — all built from the same generator loop across 14 prefixes, so what's true for one is true for (almost) all of them. This page covers every variant, including the ones that look valid but silently do nothing.

The scale

Margin and padding share one scale, 0–5 plus auto:

KeyValue
00
10.25rem
20.5rem
31rem
41.5rem
53rem
autoauto

The scale stops at 5 — there is no 6, 7, or beyond

m-6, p-7, px-6 — none of these exist, at any prefix. They have no brackets, so they don't fall back to the arbitrary matcher either; the lookup just fails and nothing is emitted, no warning. See Scale ceiling below for a live demo.

The 14 prefixes

Every prefix below shares the same scale, the same responsive variants, and the same !important form — they're generated by one loop over this exact list:

PrefixCSS property/ies
mmargin
mtmargin-top
mbmargin-bottom
msmargin-left
memargin-right
mlmargin-left (alias of ms)
mrmargin-right (alias of me)
mxmargin-left + margin-right
mymargin-top + margin-bottom
ppadding
ptpadding-top
pbpadding-bottom
pspadding-left
pepadding-right
plpadding-left (alias of ps)
prpadding-right (alias of pe)
pxpadding-left + padding-right
pypadding-top + padding-bottom

ms/me/ps/pe are physical, not RTL-logical

Despite the Bootstrap-5-style naming (start/end), these map straight to left/right — there's no direction flip under an RTL document. ml/mr/pl/pr are plain aliases of the same properties, included for anyone arriving from Tailwind.

Margin & padding

margin
padding

Directional & axis

margin
padding

Auto margins

Every one of the 14 prefixes gets an auto entry from the same loop that builds the numeric scale. On the margin side that's all genuinely useful CSS — ms-auto/me-auto is the classic push-to-the-edge trick inside a flex row:

Preview
<nav class="d-flex align-items-center">
  <span>Logo</span>
  <a class="ms-auto" href="/login">Log in</a>
</nav>

p*-auto exists but is always dead — CSS padding has no auto

p-auto, pt-auto, ps-auto, px-auto — the same generator loop produces all of these, but padding doesn't accept auto as a value at all. Every one compiles to an invalid declaration the browser silently drops. Toggle both below — p-auto changes nothing on top of p-3:
Preview

Physical aliases

Preview

Responsive

Every prefix, every scale key (including auto), at every breakpoint:

Preview

!important variant

Prefix any spacing class with ! for an !important version — this is a framework-wide mechanism, not spacing-specific, but spacing is where you'll reach for it most (overriding a component's own padding, say):

Preview

Arbitrary values

Any value in brackets works on any prefix — but there's a real distinction in what a multi-value declaration does depending on which prefix you use it on.

Single value — works on every prefix

Preview

Negative values — the only way to get negative margin

There's no named negative-margin scale, so pulling an element outward always goes through arbitrary:

Preview

Multi-value — shorthand m-[...]/p-[...] only

px-[10px_20px] is invalid — use p-[10px_20px] instead

Only the bare m/p map to the shorthand property (margin/padding), which accepts a two-value declaration. Every directional/axis prefix (mt, px, py, etc.) maps to one or two longhand properties, each of which only accepts a single value — px-[10px_20px] would apply the literal two-token string to both padding-left and padding-right, which is invalid CSS and gets silently dropped. Keep directional/axis arbitrary values to one token.
Preview

Responsive + !important compose with arbitrary too

Preview

Scale ceiling

Toggle m-6/m-7 below on top of m-5 — nothing changes, because neither class emits any CSS at all:

Preview

Past the ceiling, arbitrary is the only way to go bigger:

Preview

Gap

gap/row-gap/col-gap are also spacing — they set flex/grid item spacing rather than margin/padding, but share the same underlying 0–5 scale (built from a separate scale object with the same values). Unlike margin, there is no auto entry at all gap-auto doesn't exist, since gap: auto isn't meaningful CSS the way margin: auto is. There's also no named !important variant — only the arbitrary form supports it.

gap
row/col gap

Responsive

Preview

Arbitrary

gap is itself a shorthand (row + column), so it accepts a multi-value declaration — row-gap/col-gap don't, same rule as margin/ padding above:

Preview

Responsive + !important

Preview

Same ceiling as margin/padding

Preview

Grid gutters (g/gx/gy) are a related but separate mechanism

g/gx/gy share the same 0–5 ceiling, but they set the --st-gutter-x/--st-gutter-y custom properties the grid system reads — not a gap property directly. They're covered on the Grid page instead of here.