This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The box-decoration-break
CSS property specifies how the background
, padding
, border
, border-image
, box-shadow
, margin
, and clip-path
of an element are applied when the box for the element is fragmented.
/* Keyword values */ box-decoration-break: slice; box-decoration-break: clone; /* Global values */ box-decoration-break: initial; box-decoration-break: inherit; box-decoration-break: unset;
Initial value | slice |
---|---|
Applies to | all elements |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
The box-decoration-break
property is specified as one of the keyword values listed below.
slice
clone
border-radius
, border-image
and box-shadow
, are applied to each fragment independently. The background is drawn independently in each fragment which means that a background image with background-repeat
: no-repeat
may be repeated multiple times.slice | clone
An inline element that contains line-breaks styled with:
.example { 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; padding: 0em 1em; border-radius: 16px; border-style: solid; margin-left: 10px; font: 24px sans-serif; line-height: 2; } ... <span class="example">The<br>quick<br>orange fox</span>
Results in:
Adding box-decoration-break:clone
to the above styles:
-webkit-box-decoration-break: clone; -o-box-decoration-break: clone; box-decoration-break: clone;
Results in:
You can try the two inline examples above in your browser.
Here's an example of an inline element using a large border-radius
value. The second "iM"
has a line-break between the "i"
and the "M"
. For comparison, the first "iM"
is without line-breaks. Note that if you stack the rendering of the two fragments horizontally next to each other it will result in the non-fragmented rendering.
Try the above example in your browser.
A block element with similar styles as above, first without any fragmentation:
Fragmenting the above block into three columns results in:
Note that stacking these pieces vertically will result in the non-fragmented rendering.
Now the same example styled with box-decoration-break:clone
Note here that each fragment has an identical replicated border, box-shadow, and background.
You can try the block examples above in your browser.
Specification | Status | Comment |
---|---|---|
CSS Fragmentation Module Level 3 The definition of 'box-decoration-break' in that specification. | Candidate Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 22 -webkit- 1 | No |
32 Yes — 322 |
No |
15 -webkit- 11.5 — 15 |
6.11 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes1 | 4.4 -webkit- 1 | ? |
32 Yes — 322 |
No |
15 -webkit- 11.5 — 15 |
7.11 |
1. This property is only supported for inline elements.
2. Supported as -moz-background-inline-policy
.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/box-decoration-break