The margin-inline-start
property in CSS defines the amount of space along the outer starting edge of an element in the inline direction. It’s included in the CSS Logical Properties Level 1 specification, which is currently in Working Draft.
.element {
margin-inline-start: 25%;
writing-mode: vertical-lr;
}
The starting edge in the inline direction is determined by the element’s writing-mode
, direction
and text-orientation
. So, when using margin-inline-start
in a horizontal left-to-right context, it acts just like margin-left
as the starting edge of the element is the left side.
But if we change the writing-mode
to, say, vertical, the element is rotated clockwise, placing the starting edge toward the top. As a result, margin-inline-start
behaves just like margin-top
. Basically, the starting edge is relative to the direction it flows. That’s what we mean when talking about “logical” properties.
Syntax
margin-inline-start: <‘margin-top’>
It’s kinda weird to see the syntax of one property reference the syntax of another CSS property right in the documentation, but that’s really what it is. What it’s basically trying to say is that the property accepts the same values as margin-top
which follows this syntax:
margin-top: <length> | <percentage> | auto;
- Initial value:
0
- Applies to: all elements except internal table elements, ruby base containers, and ruby annotation containers
- Inherited: no
- Percentages: as for the corresponding physical property
- Computed value: same as corresponding
margin-*
properties - Animation type: by computed value type
Values
margin-block-start
accepts a single length or keyword value.
/* Length values */
margin-inline-start: 20px;
margin-inline-start: 2rem;
margin-inline-start: 25%;
/* Keyword values */
margin-inline-start: auto;
/* Global values */
margin-inline-start: inherit;
margin-inline-start: initial;
margin-inline-start: unset;
Demo
Click the button in the following demo to see how the starting inline edge of the element changes with the writing-mode
.
Browser support
IE | Edge | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|---|
No | 79+ | 41+ | 69+ | 12.1+ | 56+ |
Android Chrome | Android Firefox | Android Browser | iOS Safari | Opera Mobile |
---|---|---|---|---|
Yes | Yes | 81+ | 12.2+ | 59+ |
Further reading
CSS Logical Properties
Bidirectional Horizontal Rules in CSS
Building Multi-Directional Layouts
Logical layout enhancements with flow-relative shorthands
Related properties
margin
.element { margin: 50px 2rem; }
margin-block
.element { margin-block: 30px 60px; }
margin-block-end
.element { margin-block-end: 25%; }
margin-block-start
.element { margin-block-start: 25%; }
margin-inline
.element { margin-inline: 60px auto; }
margin-inline-end
.element { margin-inline-end: 3rem; }