padding

Sets the inner spacing of an element. Control individually with directional prefixes (pt, pr, pb, pl), or use the Atomic CSS exclusive shorthands px (left/right) and py (top/bottom) for convenience.

Class List

Append a value with unit after the prefix. Use px for values under 20px, rem (1rem = 10px) for 20px and above.

PrefixCSS PropertyExampleCSS Output
ppaddingp16pxpadding: 16px
ppaddingp2rempadding: 2rem (20px)
ptpadding-toppt8pxpadding-top: 8px
prpadding-rightpr16pxpadding-right: 16px
pbpadding-bottompb2-4rempadding-bottom: 2.4rem (24px)
plpadding-leftpl4rempadding-left: 4rem (40px)
pxpadding-left + padding-rightpx16pxpadding-left: 16px; padding-right: 16px
pypadding-top + padding-bottompy8pxpadding-top: 8px; padding-bottom: 8px
ppadding (% unit)p5ppadding: 5%
ptpadding-top (em)pt1empadding-top: 1em

px / py -- Horizontal / Vertical Shorthand

px and py are Atomic CSS exclusive shorthands not found in standard CSS. They set left/right or top/bottom padding at once, replacing two classes with one.

ClassCSS OutputEquivalent Individual Classes
px8pxpadding-left: 8px; padding-right: 8pxpl8px pr8px
px16pxpadding-left: 16px; padding-right: 16pxpl16px pr16px
px2rempadding-left: 2rem; padding-right: 2rempl2rem pr2rem
py4pxpadding-top: 4px; padding-bottom: 4pxpt4px pb4px
py12pxpadding-top: 12px; padding-bottom: 12pxpt12px pb12px
py4rempadding-top: 4rem; padding-bottom: 4rempt4rem pb4rem
<!-- px: apply left/right simultaneously -->
<div class="px2rem">Left/right 20px padding</div>
<!-- Same as above: -->
<div class="pl2rem pr2rem">Left/right 20px padding</div>

<!-- py: apply top/bottom simultaneously -->
<div class="py4rem">Top/bottom 40px padding</div>
<!-- Same as above: -->
<div class="pt4rem pb4rem">Top/bottom 40px padding</div>

<!-- px + py Combination (Button) -->
<button class="py8px px16px bg6366F1 cFFFFFF br8px bn cp">
  Button
</button>

px / py Visual Comparison

px2rem (left/right 20px)

px2rem

py2rem (top/bottom 20px)

py2rem

px16px py8px (button pattern)

Button

px2rem py4rem (section pattern)

Section Content

Unit Comparison

Examples of expressing the same spacing in px, rem, %, and em. Based on: html { font-size: 10px }

<tr> <th class="tal py12px px16px bg18181B bb2pxsolid27272A cA1A1AA fw600 ttu fs12px ls0-05em">spacingpxrem%em
8pxp8pxp0-8remp1pp0-8em
12pxp12pxp1-2remp2pp1-2em
16pxp16pxp1-6remp3pp1-6em
20pxp20pxp2remp5pp2em
32pxp32pxp3-2remp8pp3-2em
40pxp40pxp4remp10pp4em

Visual Comparison

See how the inner spacing of an element changes depending on the padding value.

padding: 0 (default) —

Content

No padding. Content flush against edges

padding: 4px — p4px

Content

Minimum spacing. Used for tags, badges

padding: 8px — p8px

Content

Narrow inner spacing. Small cards, inputs

padding: 16px — p16px

Content

Default inner spacing. Cards, containers

padding: 2rem (20px) — p2rem

Content

Generous spacing. Sections, modals

padding: 4rem (40px) — p4rem

Content

Wide spacing. Hero, landing sections

Common Patterns

Commonly repeated padding combinations used in practice.

<!-- Buttons by size -->
<button class="py4px px8px bg6366F1 cFFFFFF br4px bn cp fs13px">Small</button>
<button class="py8px px16px bg6366F1 cFFFFFF br8px bn cp fs14px">Medium</button>
<button class="py12px px2-4rem bg6366F1 cFFFFFF br8px bn cp fs16px">Large</button>

<!-- Card component -->
<div class="p2rem bg18181B br8px">
  <h3 class="mb8px">Card Title</h3>
  <p>Card content. Equal 20px gap in all directions</p>
</div>

<!-- Section (wide top/bottom, default left/right) -->
<section class="py4rem px2rem">
  <h2 class="mb16px">Section Title</h2>
  <p>Top/bottom 40px, left/right 20px</p>
</section>

<!-- Used with bxzbb -->
<div class="w100p p2rem bxzbb">
  Padding is included within the width (maintains 100%)
</div>

Actual appearance by pattern

button — py8px px16px

Small ButtonMedium ButtonLarge Button

card — p2rem

Card Title

Equal inner spacing with p2rem

Card Title

Wider left/right with py2rem px2-4rem

section -- py4rem px2rem

Section Content

top/bottom 40px, left/right 20px

PatternClassUsage
Small buttonpy4px px8pxBadges, tags, small buttons
Default buttonpy8px px16pxStandard buttons, link buttons
Large buttonpy12px px2-4remCTA, primary action buttons
Cardp2remCard component inner spacing
Sectionpy4rem px2remPage section wide top/bottom spacing + standard left/right spacing
Containerpx2remWrapper needing only horizontal padding
List itempy12px px16pxTable cells, list items
Inputpy8px px12pxText input field inner spacing

Tips & Notes

px / py are Atomic CSS exclusive shorthands

px16px is equivalent to pl16px pr16px, and py8px is equivalent to pt8px pb8px. Although CSS has no padding-x property, Atomic CSS provides this shorthand for convenience.

No negative padding

Unlike margin, padding cannot have negative values. Classes like neg-p do not exist. To overlap or pull elements, use neg-m (negative margin).

Padding affects box size

By default, padding increases the total size of the element. With w100px p16px, the actual width becomes 132px. Use bxzbb (box-sizing: border-box) to include padding within the width, keeping it at 100px.

Use multiples of 4

For consistent rhythm, use multiples of 4 for padding values: 4px, 8px, 12px, 16px, 2rem(20px), 2-4rem(24px), 3-2rem(32px), 4rem(40px)

Shorthand Decomposition

p (padding) is internally decomposed into 4-direction longhands. Therefore, when using shorthand and directional classes together, they work correctly regardless of order. Multi-values are also decomposed following CSS shorthand rules: p10px-20px (2 values) → top/bottom 10px, right/left 20px, p10px-20px-30px (3 values) → top 10px, right/left 20px, bottom 30px, p10px-20px-30px-40px (4 values) → top 10px, right 20px, bottom 30px, left 40px.

<!-- p2rem + pl10px → all 20px, left only 10px -->
<div class="p2rem pl10px">...</div>

<!-- Generated CSS -->
.p2rem {
  padding-top: 2rem;
  padding-right: 2rem;
  padding-bottom: 2rem;
  padding-left: 2rem;
}
.pl10px { padding-left: 10px; }
/* → padding-left precisely overridden to 10px */

<!-- Multi-value decomposition examples -->
.p10px-20px {
  padding-top: 10px;
  padding-right: 20px;
  padding-bottom: 10px;
  padding-left: 20px;
}
.p10px-20px-30px {
  padding-top: 10px;
  padding-right: 20px;
  padding-bottom: 30px;
  padding-left: 20px;
}
.p10px-20px-30px-40px {
  padding-top: 10px;
  padding-right: 20px;
  padding-bottom: 30px;
  padding-left: 40px;
}