{"id":332625,"date":"2021-01-14T07:51:52","date_gmt":"2021-01-14T15:51:52","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=332625"},"modified":"2021-01-15T12:38:42","modified_gmt":"2021-01-15T20:38:42","slug":"margin-inline-end","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/m\/margin-inline-end\/","title":{"rendered":"margin-inline-end"},"content":{"rendered":"\n

The margin-inline-end<\/code> property in CSS defines the amount of space along the outer ending edge of an element in the inline direction. It’s included in the CSS Logical Properties Level 1 specification<\/a>, which is currently in Working Draft.<\/p>\n\n\n\n\n\n\n\n

.element {\n  margin-inline-end: 25%;\n  writing-mode: vertical-lr;\n}<\/code><\/pre>\n\n\n\n

The ending edge in the inline direction is determined by the element’s writing-mode<\/code>, direction<\/code> and text-orientation<\/code>. So, when using margin-inline-end<\/code> in a horizontal left-to-right context, it acts just like margin-right<\/code> as the ending edge of the element is the right side.<\/p>\n\n\n\n

But if we change the writing-mode<\/code> to, say, vertical, the element is rotated clockwise, placing the ending edge toward the bottom. As a result, margin-inline-end<\/code> behaves just like margin-bottom<\/code>. Basically, the starting edge is relative to the direction it flows. That’s what we mean when talking about “logical” properties.<\/p>\n\n\n

Syntax<\/h3>\n\n\n
margin-inline-end: <\u2018margin-top\u2019><\/code><\/pre>\n\n\n\n

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<\/code> which follows this syntax:<\/p>\n\n\n\n

margin-top: <length> | <percentage> | auto;<\/code><\/pre>\n\n\n\n
  • Initial value:<\/strong> 0<\/code><\/li>
  • Applies to:<\/strong> all elements except internal table elements, ruby base containers, and ruby annotation containers<\/li>
  • Inherited:<\/strong> no<\/li>
  • Percentages:<\/strong> as for the corresponding physical property<\/li>
  • Computed value:<\/strong> same as corresponding margin-*<\/code> properties<\/li>
  • Animation type:<\/strong> by computed value type<\/li><\/ul>\n\n\n

    Values<\/h3>\n\n\n

    margin-block-start<\/code> accepts a single length or keyword value.<\/p>\n\n\n\n

    \/* Length values *\/\nmargin-inline-end: 20px;\nmargin-inline-end: 2rem;\nmargin-inline-end: 25%;\n\n\/* Keyword values *\/\nmargin-inline-end: auto;\n\n\/* Global values *\/\nmargin-inline-end: inherit;\nmargin-inline-end: initial;\nmargin-inline-end: unset;<\/code><\/pre>\n\n\n

    Demo<\/h3>\n\n\n

    Click the button in the following demo to see how the ending inline edge of the element changes with the writing-mode<\/code>.<\/p>\n\n\n\n