Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `margin-block-end`

`margin-block-end` sets the margin at the logical end of the block axis rather than at a fixed physical side.

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

Syntax

<'margin-top'>

margin-block-end sets the margin at the logical end of the block axis rather than at a fixed physical side.

Under writing-mode: vertical-rl, block-end is the left side. The example creates a horizontal flex flow and measures the 12px gap between items together with computed margin-left.

Grammar: <'margin-top'>.

Changing writing mode remaps this margin to another side. It can participate in margin collapsing in normal block flow; it does not collapse in the demonstrated flex layout.

Examples

<!doctype html><meta charset="utf-8"><div id="box"><i id="first"></i><i id="second"></i></div><pre id="result"></pre><script>
box.style.cssText='display:flex;flex-direction:column;writing-mode:vertical-rl;width:100px;height:50px';first.style.cssText='display:block;width:20px;height:20px;margin-block-end:12px';second.style.cssText='display:block;width:20px;height:20px';
const a=first.getBoundingClientRect(),b=second.getBoundingClientRect(),s=getComputedStyle(first);result.textContent='gap='+Math.round(a.left-b.right)+'; physical-left='+s.marginLeft+'; physical-right='+s.marginRight;
</script>

Result

gap=12; physical-left=12px; physical-right=0px

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

Sources