CSS margin-inline-end Property

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

Definition and Usage

The margin-inline-end property sets the logical inline-end margin of an element. It maps to a physical side based on writing-mode and direction.

In horizontal left-to-right layout it usually matches margin-right. In RTL it usually matches margin-left. It is one half of the margin-inline shorthand and is not inherited.

Baseline · Widely available.

Not deprecated. Broad support since about 2020. Prefer it over physical margin-right when direction can change.

CSS Syntax

syntax.css
margin-inline-end: <length> | <percentage> | auto | inherit;

Same value types as other margins. Example: margin-inline-end: 1.5rem;.

Property Values

ValueDescriptionTry it
<length>Fixed end margin such as 16px or 1emTry it
<percentage>Relative to the containing block’s inline sizeTry it
autoBrowser chooses a used value (often with flex/grid or sizing)Try it
With direction: rtlEnd maps to the physical left in horizontal RTLTry it
0 / initialNo end margin (initial value is 0)Try it
inheritTakes the parent’s margin-inline-endTry it

How to Use margin-inline-end

Use it for space after an item on the inline axis.

  1. Select the element that needs space on its inline-end side.
  2. Set a length or percentage (for example 1rem).
  3. Prefer this over margin-right when the page may use RTL.
  4. For both sides at once, use margin-inline instead.
PieceRequired?Role
Length / % / autoYesSets the inline-end outer space
Direction / writing modeAffects mappingChooses which physical edge is “end”
InheritedNoSet on each element that needs it
Sibling after itTo see a gapEnd margin pushes content that follows on the inline axis

Live Preview

Change margin-inline-end on the yellow box. The blue box shows the gap after it.

In LTR, end is on the right. Toggle RTL in the tryit editor to see it flip.

Inline row
End Next

margin-inline-end: 24px

CSS Examples

Each snippet focuses on margin-inline-end. Use Try It Yourself for a live editor.

Example 1 — End Gap

Add space after a box on the inline axis.

CSS
<style>
  .a {
    margin-inline-end: 24px;
  }
</style>

<span class="a">A</span>
<span>B</span>
Try It Yourself

How It Works

  1. Target the first item. The rule applies to .a.
  2. Set 24px. Outer space appears on the inline-end side.
  3. In LTR, that gap is on the right of A.
  4. B stays after the gap on the inline axis.

Example 2 — End Side in RTL

The same property flips with direction.

CSS
<style>
  .row {
    direction: rtl;
  }
  .a {
    margin-inline-end: 24px;
  }
</style>

<div class="row">
  <span class="a">A</span>
  <span>B</span>
</div>
Try It Yourself

How It Works

  1. Set direction: rtl. Inline start is on the right.
  2. End is on the left. The 24px gap appears after A toward the left.
  3. No left/right rewrite. The same CSS works in LTR and RTL.
  4. Compare with margin-right — physical right would not flip.

Example 3 — Space After a Label

Separate a label from following text.

CSS
<style>
  .label {
    margin-inline-end: 0.75rem;
    font-weight: 700;
  }
</style>

<span class="label">Name</span>
<span>Ada</span>
Try It Yourself

How It Works

  1. Space after the label. End margin separates it from the value.
  2. Keeps reading order. Works for LTR and RTL labels.
  3. Outside the box. Background does not extend into the gap.
  4. For inner space, use padding-inline-end instead.

Edge Cases & Pitfalls

If the gap is on the “wrong” side, check these first.

logical

End is not always right

Mapping depends on direction and writing-mode. In RTL horizontal text, end is typically left; in some vertical modes it can be top or bottom.

vs

Do not mix with margin-right for i18n

If you set both margin-inline-end and margin-right, they can fight depending on cascade and mapping. Pick logical or physical consistently.

shorthand

margin-inline resets both sides

A later margin-inline declaration overrides this longhand. Order your rules carefully.

gap

Prefer gap in flex/grid lists

For even spacing between many siblings, container gap is often cleaner than end margins on every item.

padding

Margin vs padding-inline-end

Use padding-inline-end when the background should include the space.

Browser Support

margin-inline-end is a browser CSS property for logical margins. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

margin-inline-end

Supported in all modern browsers (broad support from about 2020). Prefer it for direction-aware end margins.

96% Modern browser 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
No support
margin-inline-end Widely supported

Bottom line: Safe for modern sites. Fall back to margin-right/left only for very old browsers. It is not a runtime API.

Key Takeaways

  • Role: outer margin on the logical inline-end side.
  • Initial: 0. Not inherited.
  • Follows direction — better than margin-right for RTL.
  • Pair with start via margin-inline when both sides need space.

One line: use margin-inline-end for space after an element that stays correct when text direction changes.

Frequently Asked Questions

It sets the outer margin on the inline-end side of an element. In horizontal left-to-right layout that is usually the right side; in RTL it is usually the left.
The initial value is 0. There is no inline-end margin until you set one.
margin-right always targets the physical right edge. margin-inline-end follows writing mode and direction, so it stays on the logical end side in RTL and vertical layouts.
margin-inline is the shorthand for margin-inline-start and margin-inline-end. Use the longhand when you only need the end side.
No. Set it on each element that needs end-side spacing.
It is Baseline Widely available (broad support since about 2020). It is a browser CSS property, not a Node.js feature.

Next: margin-inline-start

Set only the logical inline-start margin.

margin-inline-start tutorial →

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