CKTIS / CSS
CSS property `margin-right`
`margin-right` sets the physical right margin and does not switch sides with text direction.
Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Syntax
<length-percentage> | auto | <anchor-size()>margin-right sets the physical right margin and does not switch sides with text direction.
Across two 200px flex rows, 10% resolves to 20px: in LTR it is the gap between items, while in RTL it is the right-edge gap before the first item. Negative -6px reduces the gap into an overlap.
Grammar: <length-percentage> | auto | <anchor-size()>.
The percentage basis is the containing block’s inline size; negative values and auto are valid. Collapsing follows the logical block axis: in horizontal writing the right side is an inline side and does not collapse, but in vertical writing it can be block-start or block-end and can collapse where normal-flow rules permit; flex and grid item margins do not participate.
Examples
<!doctype html><meta charset="utf-8"><div id="ltr"><i></i><i></i></div><div id="rtl"><i></i><i></i></div><div id="neg"><i></i><i></i></div><pre id="result"></pre><script>
const setup=(box,dir,value)=>{box.style.cssText='display:flex;direction:'+dir+';width:200px;height:30px';for(const item of box.children)item.style.cssText='display:block;width:20px;height:20px';box.firstElementChild.style.marginRight=value};setup(ltr,'ltr','10%');setup(rtl,'rtl','10%');setup(neg,'ltr','-6px');const [la,lb]=[...ltr.children].map(x=>x.getBoundingClientRect()),rp=rtl.getBoundingClientRect(),ra=rtl.firstElementChild.getBoundingClientRect(),[na,nb]=[...neg.children].map(x=>x.getBoundingClientRect()),s=getComputedStyle(rtl.firstElementChild);result.textContent='ltr-item-gap='+Math.round(lb.left-la.right)+'; rtl-right-lead='+Math.round(rp.right-ra.right)+'; physical='+s.marginRight+'; logical-start='+s.marginInlineStart+'; negative-gap='+Math.round(nb.left-na.right);
</script>Result
ltr-item-gap=20; rtl-right-lead=20; physical=20px; logical-start=20px; negative-gap=-6
The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.