Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

shape-margin — spacing around a wrapping shape

shape-margin expands the shape-outside contour, moving wrapping text away without enlarging the visible element.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

shape-margin: <length-percentage [0,∞]>;

shape-margin expands a shape-outside shape outward. It accepts a nonnegative length or percentage; its initial value is 0, and it is not inherited. Percentages refer to the containing block’s inline size, usually its width, not the shape’s width. The specification covers floats and initial letter boxes.

This spaces the wrapping contour; it neither replaces margin nor clips the image. The expanded float area cannot extend beyond the float’s margin box; add ordinary margin when necessary. The example uses float: left and shape-outside; shape-margin alone does not create circular wrapping.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>shape-margin</title>
<style>
  .demo { display: flow-root; width: 320px; font: 16px/24px monospace; }
  .shape {
    float: left;
    width: 100px;
    height: 100px;
    margin: 0 20px 20px 0;
    border-radius: 50%;
    background: teal;
    shape-outside: circle(50px at 50px 50px) border-box;
    shape-margin: 20px;
  }
</style>
<div class="demo">
  <div class="shape" aria-hidden="true"></div>
  Text wraps around this circle with extra space. Text wraps around this circle with extra space. Text wraps around this circle with extra space. Text wraps around this circle with extra space.
</div>
</html>

Result

A teal circle with text wrapping to its right around an expanded circular contour. Changing shape-margin to 0px reduces the wrapping gap without changing the circle's size.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources