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.
Fundamentals
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.
Foundation
📝 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;}
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
0
Applies to
All elements except table display types that use separate border model
Inherited
No
Animatable
Yes, as a length
Logical equivalent
margin-block-end (in horizontal LTR writing)
Reference
💎 Property Values
Value
Example
Meaning
Length
margin-bottom: 20px;
Fixed margin using px, em, rem, vw, etc.
Percentage
margin-bottom: 10%;
Margin as a percentage of the containing block width
auto
margin-bottom: auto;
Browser calculates a suitable margin; rarely used with margin-bottom
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.
Preview
👀 Live Preview
A box with bottom margin above the next line of content:
margin-bottom: 1.25rem
Content below the blue box
Hands-On
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>
For simple English pages, margin-bottom is familiar and widely used. Choose margin-block-end when layouts must adapt to writing mode.
Context
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.
A11y
♿ 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.
Compatibility
🖥 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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Legacy & Chromium
Full support
OperaAll versions · Modern & legacy
Full support
margin-bottom property99% supported
Bottom line: Safe to use everywhere. For writing-mode-aware spacing, see margin-block-end.
Wrap Up
🎉 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.