Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `margin-inline-end`

`margin-inline-end` sets the outer margin at the logical end of the inline axis; writing mode and text direction determine its physical side.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

<'margin-top'>

margin-inline-end sets the outer margin at the logical end of the inline axis; writing mode and text direction determine its physical side.

The example exposes three boundaries: in horizontal RTL, inline-end is the left side and 10% of a 200px inline size creates a 20px gap; in vertical LTR it is the bottom and 10% of a 100px inline size creates 10px; -6px overlaps adjacent items.

Grammar: <'margin-top'>.

A percentage uses the containing block’s inline size. Negative values are allowed, inline-axis margins do not collapse, and auto absorbs free space only in a layout that distributes it.

Examples

<!doctype html><meta charset="utf-8"><div id="h"><i></i><i></i></div><div id="v"><i></i><i></i></div><div id="n"><i></i><i></i></div><pre id="result"></pre><script>
const setup=(box,css,value)=>{box.style.cssText='display:flex;'+css;for(const item of box.children)item.style.cssText='display:block;width:20px;height:20px';box.firstElementChild.style.marginInlineEnd=value};setup(h,'direction:rtl;width:200px;height:30px','10%');setup(v,'writing-mode:vertical-rl;direction:ltr;width:30px;height:100px','10%');setup(n,'direction:ltr;width:100px;height:30px','-6px');const [ha,hb]=[...h.children].map(x=>x.getBoundingClientRect()),[va,vb]=[...v.children].map(x=>x.getBoundingClientRect()),[na,nb]=[...n.children].map(x=>x.getBoundingClientRect()),hs=getComputedStyle(h.firstElementChild),vs=getComputedStyle(v.firstElementChild);result.textContent='rtl-left-gap='+Math.round(ha.left-hb.right)+'; rtl-physical='+hs.marginLeft+'; vertical-bottom-gap='+Math.round(vb.top-va.bottom)+'; vertical-physical='+vs.marginBottom+'; negative-gap='+Math.round(nb.left-na.right);
</script>

Result

rtl-left-gap=20; rtl-physical=20px; vertical-bottom-gap=10; vertical-physical=10px; negative-gap=-6

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources