Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Box Model and Sizing

The box-decoration-break property

Reference for the CSS box-decoration-break property: decide whether padding, borders and backgrounds are sliced or repeated when a box breaks across lines or columns.

An inline element such as a <span> that wraps onto several lines is drawn as several fragments. By default the browser treats it as one box that was sliced: the left padding and border appear only on the first fragment, the right on the last. The box-decoration-break property lets you decorate every fragment as a complete box instead.

CSS
.highlight {
  box-decoration-break: clone;
}

Try it

Slice or clone across lines

With slice, the border and rounded corners are missing where the phrase is cut. With clone, every line gets its own padding, border and corners.

Syntax

CSS
box-decoration-break: slice | clone
  • Initial value: slice
  • Applies to: all elements
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: as specified

Values

Value Description
slice The box is laid out as if it were one unbroken box and then cut at the break. Padding, border and margin at the break are not repeated, and a background continues across fragments as one image.
clone Each fragment is decorated independently: padding, border, margin and border-radius are applied on every fragment, and the background is drawn separately in each.

Usage notes

  • Inline highlights. The main use is a highlighted or boxed phrase in running text. Without clone, rounded corners and borders look broken at line wraps.
  • Columns and pages. It also affects a block that is split across columns, regions or printed pages, where clone gives each piece its own border and padding.
  • Gradients and shadows. With slice, a gradient background spans the whole phrase as if on a single line; with clone, the gradient restarts on each fragment. Box shadows are also drawn per fragment with clone.
  • Vendor prefix. Older versions of Chromium and Safari needed -webkit-box-decoration-break; including both is harmless.
  • Tip. For a quick highlighter look, combine clone with a small vertical padding and generous line-height, so fragments on adjacent lines do not overlap.

Browser support

Supported in current versions of all major browsers, though some Chromium and Safari versions historically required the -webkit- prefix for inline boxes.