margin-bottom

Sets the bottom outer spacing of an element. Use the mb prefix followed by a value with unit. The most frequently used margin direction for paragraph spacing, heading bottom margins, vertical card spacing, etc.

Class Patterns

Prefix mb + value + unit. Use px for under 20px, rem(1rem = 10px) for 20px and above.

ClassCSS OutputDescription
mb4pxmargin-bottom: 4pxminimum spacing
mb8pxmargin-bottom: 8pxNarrow spacing
mb12pxmargin-bottom: 12pxDefault spacing
mb16pxmargin-bottom: 16pxGenerous spacing
mb2remmargin-bottom: 2rem (20px)rem unit start
mb2-4remmargin-bottom: 2.4rem (24px)Decimals are expressed with hyphens
mb3-2remmargin-bottom: 3.2rem (32px)Wide spacing
mb4remmargin-bottom: 4rem (40px)Between-section spacing
mbamargin-bottom: autoAuto margin (used for flexbox/grid alignment)

Unit Comparison

Comparison of the same size expressed in px and rem. Based on: html { font-size: 10px }

Sizepx classrem class
8pxmb8pxmb0-8rem
12pxmb12pxmb1-2rem
16pxmb16pxmb1-6rem
20pxmb20pxmb2rem
24pxmb24pxmb2-4rem
32pxmb32pxmb3-2rem
40pxmb40pxmb4rem

Common Values

ClassActual sizeUsage
mb4px4pxFine gap between title and subtitle
mb8px8pxNarrow gap between paragraphs
mb16px16pxDefault gap below heading
mb2rem20pxGap between content blocks
mb3-2rem32pxGap below tables and demo areas
mb4rem40pxPage section ending gap

Code Examples

<!-- Gap below title -->
<h1 class="mb16px">Page Title</h1>
<p class="mb8px">First paragraph</p>
<p class="mb8px">Second paragraph</p>

<!-- Form field gap -->
<div>
  <label class="db mb4px">Name</label>
  <input type="text" class="w100p mb16px" />
  <label class="db mb4px">Email</label>
  <input type="email" class="w100p mb16px" />
  <button>Submit</button>
</div>

<!-- Card list (using mb instead of gap) -->
<div class="mb2rem bg18181B p2rem br8px">Card 1</div>
<div class="mb2rem bg18181B p2rem br8px">Card 2</div>
<div class="bg18181B p2rem br8px">Card 3 (no mb on last)</div>

Auto Value

mba applies margin-bottom: auto. Used to push elements upward in flex containers.

<!-- Push element up in flex container -->
<div class="df fdc h40rem">
  <header class="mba p2rem bg18181B">Pushed up (always at top)</header>
  <main class="p2rem">Takes remaining space</main>
</div>

Negative Margin (neg- prefix)

Use neg-mb to apply negative margin-bottom. Used to reduce or overlap spacing with the element below.

ClassCSSDescription
neg-mb8pxmargin-bottom: -8px8px overlap with element below
neg-mb16pxmargin-bottom: -16px16px overlap with element below
neg-mb2remmargin-bottom: -2rem20px overlap with element below
<!-- Element overlap effect -->
<div class="bg6366F1 p2rem cFFFFFF neg-mb16px">
  Overlaps 16px below
</div>
<div class="bg18181B p2rem pt3-2rem cFAFAFA">
  Overlapping element (compensated with pt)
</div>

Tips & Notes

Margin Collapse

mb and the next element's mt collapse. For example, mb2rem + mt2rem results in 20px, not 40px. No collapse occurs in flex/grid.

Prefer gap over mb

For list item spacing, using df fdc gap8px on the parent is cleaner since you don't need to handle the last element.