The margin-inline property is a modern CSS logical property used to control horizontal margins based on the writing direction of the document.
Instead of using:
[code theme="dark"] margin-left margin-right [/code]you can use:
[code theme="dark"] margin-inline [/code]This makes layouts more flexible and international-friendly because the spacing automatically adjusts for:
This applies:
Meaning:
In normal English layouts (LTR):
One of the biggest advantages of logical properties is automatic RTL support.
LTR Example (English)
[code theme="dark"] margin-inline:10px 30px; [/code]Result:
RTL Example (Arabic)
[code theme="dark"] direction:rtl; margin-inline:10px 30px; [/code]Result:
Very commonly used for centering layouts.
[code theme="dark"] .container{ width:1200px; margin-inline:auto; } [/code]This automatically centers the container horizontally.
Traditional CSS:
[code theme="dark"] margin-left:auto; margin-right:auto; [/code]Modern CSS:
[code theme="dark"] margin-inline:auto; [/code]Controls only the starting side.
[code theme="dark"] margin-inline-start:20px; [/code]Equivalent to:
Controls only the ending side.
[code theme="dark"] margin-inline-end:20px; [/code]Equivalent to:
This centers the card regardless of writing direction.
| Physical Property | Logical Property |
|---|---|
| margin-left | margin-inline-start |
| margin-right | margin-inline-end |
| margin-left + margin-right | margin-inline |
Modern browsers support margin-inline very well, making it safe for most modern projects.
If supporting extremely old browsers, developers may still use:
[code theme="dark"] margin-left margin-right [/code]as fallback properties.
is now considered a stable and recommended modern CSS feature for responsive and international-friendly layouts.