CSS margin-bottom Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Box Model

What You’ll Learn

The margin-bottom property adds outer space below an element. It is one of the most common tools for vertical spacing in CSS layouts.

01

Bottom Space

Outside border.

02

Box Model

Outer spacing.

03

Stack gaps

Separate blocks.

04

Units

px, rem, %.

05

Collapse

Vertical margins.

06

Default 0

No spacing.

Introduction

The margin-bottom property in CSS is used to set the space outside the bottom edge of an element.

This property is part of the CSS Box Model and helps control the layout of web pages by adding space between elements. By adjusting the margin-bottom, you can ensure that elements on your page are spaced appropriately and do not overlap.

Definition and Usage

Apply margin-bottom when you need spacing below a single side of an element without changing top, left, or right margins. It is ideal for separating paragraphs, cards, form fields, and section blocks in vertical stacks.

💡
Beginner Tip

margin-bottom creates space outside the border below the element. Use padding-bottom when you need space inside the border.

📝 Syntax

The syntax for the margin-bottom property is simple and can accept various units for the value.

syntax.css
element {
  margin-bottom: value;
}

Here, value can be a length, percentage, or the keyword auto.

Basic Example

margin-bottom.css
p {
  margin-bottom: 20px;
}

⚡ Quick Reference

QuestionAnswer
Initial value0
Applies toAll elements except table display types that use separate border model
InheritedNo
AnimatableYes, as a length
Logical equivalentmargin-block-end (in horizontal LTR writing)

💎 Property Values

ValueExampleMeaning
Lengthmargin-bottom: 20px;Fixed margin using px, em, rem, vw, etc.
Percentagemargin-bottom: 10%;Margin as a percentage of the containing block width
automargin-bottom: auto;Browser calculates a suitable margin; rarely used with margin-bottom
inheritmargin-bottom: inherit;Takes the computed value from the parent element
initialmargin-bottom: initial;Resets to the default value (0)
margin-bottom: 1rem; margin-bottom: 24px; margin-bottom: 5%;

🎯 Default Value

The default value of the margin-bottom property is 0. This means that there is no additional space outside the bottom edge of the element unless explicitly set.

👀 Live Preview

A box with bottom margin above the next line of content:

margin-bottom: 1.25rem

Content below the blue box

Examples Gallery

Add bottom margin to paragraphs, space stacked cards, use rem for typography rhythm, and compare with the logical equivalent.

🔢 Bottom Spacing

Start with the reference example — set bottom margin on paragraph elements.

Example 1 — Paragraph Bottom Margin

In this example, we set the bottom margin of a paragraph element to 20 pixels.

margin-bottom.html
<style>
  p {
    margin-bottom: 20px;
  }
</style>

<p>This paragraph has a bottom margin of 20px.</p>
<p>The space between this paragraph and the one above is due to the bottom margin.</p>
Try It Yourself

How It Works

Only the bottom outer edge gets spacing. The second paragraph sits below the gap created by the first paragraph’s margin-bottom.

Example 2 — Stacked Cards

Use bottom margin to separate stacked UI cards in a vertical list.

margin-bottom-stack.css
.card {
  margin-bottom: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
}

.card:last-child {
  margin-bottom: 0;
}
Try It Yourself

How It Works

Bottom margin creates vertical rhythm in a stack. Reset margin on the last item to avoid extra space at the bottom of the list.

📈 Typography & Logical Properties

Use scalable units for content spacing and understand the logical property equivalent.

Example 3 — rem for Content Rhythm

Use rem units so bottom spacing scales with the root font size.

margin-bottom-rem.css
.article p {
  margin-bottom: 1.25rem;
  line-height: 1.6;
}
Try It Yourself

How It Works

1.25rem scales with the user’s root font size, making paragraph spacing more accessible than fixed pixels alone.

Example 4 — Physical vs Logical

In horizontal LTR writing, margin-bottom matches margin-block-end:

margin-bottom-logical.css
/* Physical */
.note {
  margin-bottom: 1.5rem;
}

/* Logical equivalent in horizontal LTR */
.note {
  margin-block-end: 1.5rem;
}
Try It Yourself

How It Works

For simple English pages, margin-bottom is familiar and widely used. Choose margin-block-end when layouts must adapt to writing mode.

margin-bottom in the Box Model

Margin sits outside the border. Bottom margin specifically adds transparent space below the element:

  • Content — text or child elements inside the box.
  • Padding — inner space between content and border.
  • Border — the visible edge.
  • Margin-bottom — outer space below the border.
Margin Collapse

When two block elements stack, their vertical margins can collapse into the larger value. This is normal CSS behavior in document flow.

♿ Accessibility

  • Keep readable paragraph spacing — Bottom margin helps separate blocks of text for easier reading.
  • Do not rely on empty elements for spacing — Use margin instead of blank divs.
  • Test zoomed layouts — Large bottom margins can push content off-screen on small viewports.
  • Maintain touch target spacing — Buttons and links benefit from enough margin so they are easy to tap.
  • Combine with semantic HTML — Margins adjust spacing; structure still comes from proper elements.

🧠 How margin-bottom Works

1

You set bottom spacing

Apply margin-bottom with px, rem, %, or a keyword.

CSS rule
2

Browser reserves space

Transparent margin area is added below the border on the bottom edge.

Box model
3

Content below shifts down

Neighboring elements move away, creating vertical separation.

Layout
=

Clean vertical rhythm

Stacked elements breathe with clear gaps between them.

🖥 Browser Compatibility

The margin-bottom property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is a widely used property and should work consistently across different platforms and devices.

Universal · All browsers

Core layout spacing everywhere

margin-bottom is one of the most fundamental CSS properties. You can rely on it in any project.

99% Global browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Legacy & Chromium
Full support
Opera All versions · Modern & legacy
Full support
margin-bottom property 99% supported

Bottom line: Safe to use everywhere. For writing-mode-aware spacing, see margin-block-end.

🎉 Conclusion

The margin-bottom property is a fundamental aspect of CSS layout design, allowing you to control the spacing around elements on your web pages.

By understanding how to use this property effectively, you can create clean and organized layouts that enhance the user experience. Experiment with different values to see how they affect the layout of your elements and achieve the desired spacing in your design.

💡 Best Practices

✅ Do

  • Use margin-bottom for spacing between stacked blocks
  • Prefer rem for scalable paragraph spacing
  • Reset margin on the last item in a list when needed
  • Combine with other margin longhands for precise control
  • Consider margin-block-end for multilingual layouts

❌ Don’t

  • Confuse margin-bottom with padding-bottom
  • Use empty divs only to create spacing
  • Use huge fixed margins that break mobile layouts
  • Forget vertical margin collapse between blocks
  • Apply bottom margin when flex or grid gap would be cleaner

Key Takeaways

Knowledge Unlocked

Five things to remember about margin-bottom

Use these points when spacing elements below the bottom edge.

5
Core concepts
0 02

Default 0

No spacing.

Default
rem 03

Scalable

Use rem.

Units
col 04

Collapse

Vertical margins.

Behavior
pad 05

Not padding

Inside vs out.

Box model

❓ Frequently Asked Questions

The margin-bottom property sets outer spacing below an element, outside of its border. It pushes content below the element further away.
The default value is 0, meaning there is no bottom margin unless you set one explicitly.
margin-bottom adds space outside the border between elements. padding-bottom adds space inside the border between the border and the content.
margin-bottom always targets the physical bottom edge. margin-block-end follows the writing mode and adapts when text flow or direction changes.
Yes. Vertical margins between block elements can collapse. The larger margin wins when two block elements stack vertically.

Practice in the Live Editor

Open the HTML editor, try different margin-bottom values, and see how bottom spacing changes your layout.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful