The margin-block property sets outer spacing on the block axis using logical sides instead of physical top and bottom.
01
Block Axis
Start and end.
02
Shorthand
1 or 2 values.
03
Writing Mode
Adapts to flow.
04
Logical
Not top/bottom.
05
Longhand
start + end.
06
Default 0
No spacing.
Fundamentals
Introduction
The margin-block property in CSS is a shorthand property that allows you to set the margin on the block start and block end sides of an element. In a block-level context, the block start refers to the top, and the block end refers to the bottom. However, in a writing mode where text flows vertically, these terms adapt accordingly.
This property provides a convenient way to control vertical margins in layouts, respecting the text direction and writing mode of the document.
Definition and Usage
Apply margin-block when you want block-axis spacing that stays correct in multilingual layouts, RTL pages, or vertical writing modes. Use one value for equal block-start and block-end margins, or two values for different spacing on each side.
💡
Beginner Tip
In normal horizontal English pages, margin-block: 20px 10px behaves like margin-top: 20px and margin-bottom: 10px. The difference appears when writing mode changes.
Foundation
📝 Syntax
The syntax for the margin-block property allows you to specify values for both the block start and block end margins.
syntax.css
element{margin-block:<margin-start><margin-end>;}
<margin-start> — The margin for the block start side (top in horizontal writing modes).
<margin-end> — The margin for the block end side (bottom in horizontal writing modes).
If only one value is provided, it applies to both the block start and block end sides.
Basic Example
margin-block.css
p{margin-block:20px10px;}
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
Longhand properties
margin-block-start, margin-block-end
Reference
💎 Property Values
Value
Example
Meaning
Length
margin-block: 20px 10px;
Fixed margin in px, em, rem, etc.
Percentage
margin-block: 5%;
Margin as a percentage of the containing block width
auto
margin-block: auto;
Browser calculates the margin
inherit
margin-block: inherit;
Inherits the margin value from the parent element
initial
margin-block: initial;
Sets the property to its default value (0)
unset
margin-block: unset;
Resets to inherit or initial depending on context
block-startblock-end
Default
🎯 Default Value
The default value for the margin-block property is 0, meaning there is no margin applied unless specified otherwise. You can override it with one or two values, or with the longhand properties margin-block-start and margin-block-end.
Preview
👀 Live Preview
A box with unequal block-start and block-end margins inside a dashed container:
margin-block: 1.25rem 0.75rem
Hands-On
Examples Gallery
Set different block-start and block-end margins, use a single value, see writing-mode behavior, and compare with longhand properties.
🔢 Block-Axis Spacing
Start with the reference example — set different margins on block start and block end.
Example 1 — Two-Value margin-block
Set a margin of 20px at the top and 10px at the bottom of a paragraph element.
margin-block.html
<style>p{margin-block:20px10px;}</style><p>This paragraph has a margin of 20px at the top and 10px at the bottom.</p>
Use longhand when you need to change only one block side. Use shorthand when both sides share a simple pattern.
Context
Logical vs Physical Margins
Logical
Physical (horizontal writing)
margin-block-start
margin-top
margin-block-end
margin-bottom
margin-inline-start
margin-left (LTR)
margin-inline-end
margin-right (LTR)
⚠
When to choose logical properties
Prefer margin-block when your layout must work across writing modes and directions. Physical margins are fine for simple single-language pages.
A11y
♿ Accessibility
Preserve reading order — Logical margins respect direction and writing mode, which helps RTL and multilingual users.
Keep section spacing consistent — Use block-axis margins for vertical rhythm between headings and paragraphs.
Do not hide content with negative margins — Negative block margins can overlap focusable elements.
Test zoom and small screens — Large block margins can push content off-screen on narrow viewports.
Combine with semantic HTML — Margins adjust spacing; structure still comes from proper elements.
🧠 How margin-block Works
1
You set block-axis spacing
Apply margin-block with one or two values for block-start and block-end.
CSS rule
2
Browser maps logical sides
Block-start and block-end are resolved from writing mode and direction.
Logical layout
3
Outer space is reserved
Transparent margin area is added on the block axis, pushing neighbors apart.
Box model
=
↕
Adaptable vertical rhythm
Spacing stays meaningful when writing mode or text direction changes.
Compatibility
🖥 Browser Compatibility
The margin-block property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. As always, it is advisable to test your website across different browsers to ensure consistent behavior.
✓ Modern browsers · Logical properties
Reliable in current browser versions
margin-block is part of the CSS Logical Properties module. Use it in modern projects; provide physical fallbacks only if you must support very old browsers.
96%Global browser support
Google Chrome87+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari14.1+ · macOS & iOS
Full support
Microsoft Edge87+ · Chromium
Full support
Opera73+ · Modern
Full support
margin-block property96% supported
Bottom line: Safe for modern sites. For side-specific control, see margin-block-end.
Wrap Up
🎉 Conclusion
The margin-block property is a useful shorthand for setting vertical margins on block-level elements, especially in documents with diverse writing modes and directions.
It simplifies layout management by providing a unified way to handle block margins, adapting to the document’s writing mode. By using this property, you can create more adaptable and responsive layouts.
Pair with other logical properties for consistent layouts
Use one value when block-start and block-end should match
Test with different writing modes when building international UIs
❌ Don’t
Mix logical and physical margins on the same axis without reason
Assume block-start always means top in every layout
Use huge fixed margins that break mobile layouts
Forget margin collapse between stacked block elements
Skip browser testing for older Safari versions
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about margin-block
Use these points when spacing elements on the block axis.
5
Core concepts
↕01
Block Axis
Start and end.
Purpose
002
Default 0
No spacing.
Default
203
Two values
Start and end.
Syntax
wm04
Writing mode
Adapts flow.
Logical
LH05
Longhand
start + end.
Related
❓ Frequently Asked Questions
The margin-block property is a shorthand that sets outer spacing on the block-start and block-end sides of an element. In horizontal writing, that is usually top and bottom.
The default value is 0, meaning no block-axis margin unless you set one explicitly.
margin-top and margin-bottom always target physical top and bottom. margin-block follows the writing mode, so spacing stays correct when text flow or direction changes.
It is shorthand for margin-block-start and margin-block-end.
Use it when you want vertical spacing that adapts to writing mode and direction, especially in multilingual or RTL layouts.