box-decoration-break
The box-decoration-break
CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.
Try it
The specified value will impact the appearance of the following properties:
Syntax
/* Keyword values */
box-decoration-break: slice;
box-decoration-break: clone;
/* Global values */
box-decoration-break: inherit;
box-decoration-break: initial;
box-decoration-break: revert;
box-decoration-break: revert-layer;
box-decoration-break: unset;
The box-decoration-break
property is specified as one of the keyword values listed below.
Values
slice
-
The element is initially rendered as if its box were not fragmented, after which the rendering for this hypothetical box is sliced into pieces for each line/column/page. Note that the hypothetical box can be different for each fragment since it uses its own height if the break occurs in the inline direction, and its own width if the break occurs in the block direction. See the CSS specification for details.
clone
-
Each box fragment is rendered independently with the specified border, padding, and margin wrapping each fragment. The
border-radius
,border-image
, andbox-shadow
are applied to each fragment independently. The background is also drawn independently for each fragment, which means that a background image withbackground-repeat: no-repeat
may nevertheless repeat multiple times.
Formal definition
Initial value | slice |
---|---|
Applies to | all elements |
Inherited | no |
Computed value | as specified |
Animation type | discrete |
Formal syntax
box-decoration-break =
slice |
clone
Examples
Inline box fragments
An inline element with a box decoration may have unexpected appearance when it contains line breaks due to the initial slice
value.
The following example shows the effect of adding box-decoration-break: clone
to a <span>
that contains <br>
tags:
span {
background: linear-gradient(to bottom right, yellow, green);
box-shadow:
8px 8px 10px 0px deeppink,
-5px -5px 5px 0px blue,
5px 5px 15px 0px yellow;
}
#clone {
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
<p>
<span>The<br />quick<br />orange fox</span>
</p>
<p>
<span id="clone">The<br />quick<br />orange fox</span>
</p>
Block box fragments
The following example shows how block elements with box decoration look when they contain line breaks in a multi-column layout.
Notice how the result of box-decoration-break: slice
would be the equivalent of the first <div>
if stacked vertically.
span {
display: block;
background: linear-gradient(to bottom right, yellow, green);
box-shadow:
inset 8px 8px 10px 0px deeppink,
inset -5px -5px 5px 0px blue,
inset 5px 5px 15px 0px yellow;
}
#base {
width: 33%;
}
.columns {
columns: 3;
}
.clone {
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
<div id="base">
<span>The<br />quick<br />orange fox</span>
</div>
<br />
<h2>'box-decoration-break: slice'</h2>
<div class="columns">
<span>The<br />quick<br />orange fox</span>
</div>
<h2>'box-decoration-break: clone'</h2>
<div class="columns">
<span class="clone">The<br />quick<br />orange fox</span>
</div>
Specifications
Specification |
---|
CSS Fragmentation Module Level 3 # break-decoration |
Browser compatibility
BCD tables only load in the browser