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.
| Prefix | CSS Property | Example | CSS Output |
|---|---|---|---|
p | padding | p16px | padding: 16px |
p | padding | p2rem | padding: 2rem (20px) |
pt | padding-top | pt8px | padding-top: 8px |
pr | padding-right | pr16px | padding-right: 16px |
pb | padding-bottom | pb2-4rem | padding-bottom: 2.4rem (24px) |
pl | padding-left | pl4rem | padding-left: 4rem (40px) |
px | padding-left + padding-right | px16px | padding-left: 16px; padding-right: 16px |
py | padding-top + padding-bottom | py8px | padding-top: 8px; padding-bottom: 8px |
p | padding (% unit) | p5p | padding: 5% |
pt | padding-top (em) | pt1em | padding-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.
| Class | CSS Output | Equivalent Individual Classes |
|---|---|---|
px8px | padding-left: 8px; padding-right: 8px | pl8px pr8px |
px16px | padding-left: 16px; padding-right: 16px | pl16px pr16px |
px2rem | padding-left: 2rem; padding-right: 2rem | pl2rem pr2rem |
py4px | padding-top: 4px; padding-bottom: 4px | pt4px pb4px |
py12px | padding-top: 12px; padding-bottom: 12px | pt12px pb12px |
py4rem | padding-top: 4rem; padding-bottom: 4rem | pt4rem 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)
py2rem (top/bottom 20px)
px16px py8px (button pattern)
px2rem py4rem (section pattern)
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">spacing | px | rem | % | em |
|---|---|---|---|---|
| 8px | p8px | p0-8rem | p1p | p0-8em |
| 12px | p12px | p1-2rem | p2p | p1-2em |
| 16px | p16px | p1-6rem | p3p | p1-6em |
| 20px | p20px | p2rem | p5p | p2em |
| 32px | p32px | p3-2rem | p8p | p3-2em |
| 40px | p40px | p4rem | p10p | p4em |
Visual Comparison
See how the inner spacing of an element changes depending on the padding value.
padding: 0 (default) —
No padding. Content flush against edges
padding: 4px — p4px
Minimum spacing. Used for tags, badges
padding: 8px — p8px
Narrow inner spacing. Small cards, inputs
padding: 16px — p16px
Default inner spacing. Cards, containers
padding: 2rem (20px) — p2rem
Generous spacing. Sections, modals
padding: 4rem (40px) — p4rem
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
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
| Pattern | Class | Usage |
|---|---|---|
| Small button | py4px px8px | Badges, tags, small buttons |
| Default button | py8px px16px | Standard buttons, link buttons |
| Large button | py12px px2-4rem | CTA, primary action buttons |
| Card | p2rem | Card component inner spacing |
| Section | py4rem px2rem | Page section wide top/bottom spacing + standard left/right spacing |
| Container | px2rem | Wrapper needing only horizontal padding |
| List item | py12px px16px | Table cells, list items |
| Input | py8px px12px | Text 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;
}