Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `margin-block-start`

`margin-block-start` sets the margin at the logical start of the block axis, which depends on the writing mode.

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

Syntax

<'margin-top'>

margin-block-start sets the margin at the logical start of the block axis, which depends on the writing mode.

Under writing-mode: vertical-rl, block-start is the right side. The example measures the first item’s 12px gap from the right edge and its computed margin-right.

Grammar: <'margin-top'>.

This property is not synonymous with margin-top. The margin can collapse in normal block flow, but a flex item’s margin does not collapse.

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-start:12px';second.style.cssText='display:block;width:20px;height:20px';
const p=box.getBoundingClientRect(),a=first.getBoundingClientRect(),s=getComputedStyle(first);result.textContent='right-gap='+Math.round(p.right-a.right)+'; physical-right='+s.marginRight+'; physical-left='+s.marginLeft;
</script>

Result

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

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

Sources