CSS margin-block-start Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The margin-block-start property sets the outer margin on the block-start edge of an element. In a horizontal writing mode (the usual default), that maps to the physical top — like margin-top.

With a vertical writing-mode, it can map to left or right instead. It is one half of the margin-block shorthand (with margin-block-end). It is not inherited. The initial value is 0.

Baseline · Widely available.

Not deprecated. Cross-browser since about January 2020. Prefer it over margin-top when writing mode may change.

Logical tip.

Use margin-block-start for space before the element in the writing flow. Pair with margin-block-end when you need both sides separately.

CSS Syntax

syntax.css
margin-block-start: <length> | <percentage> | auto | initial | inherit;

Same value types as margin-top, but the side is logical.

Property Values

ValueDescriptionTry it
<length>Fixed size such as 1rem or 20pxTry it
<percentage>Percent of the containing block (layout-dependent, often its width)Try it
autoBrowser chooses the block-start marginTry it
With writing-modeShows how block-start maps when text flows verticallyTry it
initialResets to 0Try it
inheritInherits from the parent elementTry it

How to Use margin-block-start

Think “space before this box in the writing flow,” not always “top.”

  1. Decide how much gap you want before the element on the block axis.
  2. Set margin-block-start with a length, percentage, or auto.
  3. Use margin-block-end if you also need space after the element.
  4. Test with writing-mode if orientation may change.
In horizontal-tbUsually maps to
margin-block-startmargin-top
margin-block-start: 1remLike margin-top: 1rem

Live Preview

The middle (amber) box is the target. Change margin-block-start in a horizontal writing mode.

In this preview, block-start is the top edge.

Boxes
Above
Target
Below

margin-block-start: 0

CSS Examples

Each snippet shows only margin-block-start (plus writing-mode when needed). Use Try It Yourself for a live editor.

Example 1 — Length Value

A fixed length adds space before the box on the block axis.

CSS
<style>
  .box {
    margin-block-start: 1rem;
  }
</style>

<div class="box">Target</div>
Try It Yourself

How It Works

  1. One side only. margin-block-start: 1rem affects the block-start edge.
  2. Horizontal default. That usually means the top gets 1rem.
  3. Neighbor moves. Space appears before the target (after the box above).
  4. End unchanged. Block-end (often bottom) stays at its previous value.

Example 2 — Percentage

A percentage sizes the block-start margin relative to the containing block.

CSS
<style>
  .box {
    margin-block-start: 5%;
  }
</style>

<div class="box">Target</div>
Try It Yourself

How It Works

  1. Percent, not height. The percentage is layout-dependent (often based on containing-block width).
  2. Still block-start. Only the start edge receives that spacing.
  3. Scales with container. Wider parents can produce a larger gap.
  4. Prefer rem/px when you need a predictable fixed gap.

Example 3 — Vertical Writing Mode

Block-start follows the writing mode, not always the physical top.

CSS
<style>
  .stack {
    writing-mode: vertical-rl;
  }

  .box {
    margin-block-start: 1rem;
  }
</style>

<div class="stack">
  <div class="box">Target</div>
</div>
Try It Yourself

How It Works

  1. Change the flow. writing-mode: vertical-rl makes lines run vertically.
  2. Keep logical margin. margin-block-start still means the start of the block axis.
  3. Physical side changes. The gap may appear on left/right instead of top.
  4. Why it matters. One rule stays correct when orientation changes.

Edge Cases & Pitfalls

Logical “start” is easy to mix up with physical top.

mapping

Not always the top

In vertical writing modes, block-start can map to physical left or right. Check writing-mode before debugging.

collapse

Block margins can still collapse

In normal flow, adjacent block-axis margins may collapse just like classic top/bottom margins.

shorthand

Physical margin can override

A later margin shorthand sets all four physical sides and can wipe this longhand depending on cascade order.

pair

Only one edge

margin-block-start does not set block-end. Use margin-block-end or the margin-block shorthand for both.

Browser Support

margin-block-start is a browser CSS property (logical box model). Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

margin-block-start

Supported in modern browsers since about January 2020. Part of CSS Logical Properties and Values.

96% Modern support
Google Chrome 69+
Full support
Mozilla Firefox 41+
Full support
Apple Safari 12.1+
Full support
Microsoft Edge 79+
Full support
Opera 56+
Full support
Samsung Internet 10+
Full support
Internet Explorer —
No support
margin-block-start Modern browsers

Bottom line: Safe for modern sites. Fall back to margin-top only if you must support Internet Explorer. It is not a runtime API.

Key Takeaways

  • Role: outer margin on the block-start edge only.
  • Logical: follows writing mode — usually top in horizontal text.
  • Shorthand: part of margin-block with margin-block-end.
  • Default: 0 — not inherited.

One line: margin-block-start adds space before the element on the block axis — writing-mode aware.

Frequently Asked Questions

It sets the outer margin on the block-start edge. In a horizontal writing mode, that is usually the top. The physical side can change with writing-mode.
The default is 0, so there is no block-start margin until you set one.
margin-top always means physical top. margin-block-start follows writing mode, so in vertical text it may map to left or right instead.
margin-block is the shorthand for margin-block-start and margin-block-end. Use the longhand when you only need the start side.
Use it for spacing before an element on the block axis—above a section or after a heading—especially when writing mode may change.
It is Baseline and widely available in modern browsers since about January 2020. It is a browser CSS property, not a Node.js feature.

Next: margin-bottom

Learn the physical bottom margin property.

margin-bottom tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

8 people found this page helpful