Web/CSS/box-decoration-break

From Get docs


The box-decoration-break CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.


The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

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: initial;
box-decoration-break: inherit;
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, and box-shadow are applied to each fragment independently. The background is also drawn independently for each fragment, which means that a background image with background-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

slice | clone

Examples

Inline box fragments

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:

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8167/315321bf1f82344b673a53f67f4b6826/box-decoration-break-inline-slice.png|A screenshot of the rendering of an inline element styled with box-decoration-break:slice and styles given in the example.]]

Adding box-decoration-break: clone to the above styles:

-webkit-box-decoration-break: clone;
box-decoration-break: clone;

... results in:

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8169/a1b14bd1f0171aa0c62e1fb80c354d91/box-decoration-break-inline-clone.png|A screenshot of the rendering of an inline element styled with box-decoration-break:clone and styles given in the example]]

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.

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8189/c334af935058234a6f8682ca6ecad4fe/box-decoration-break-slice-inline-2.png|A screenshot of the rendering of the second inline element example.]]

Try the above example in your browser.

Block box fragments

A block element with similar styles as above and no fragmentation results in:

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8181/ee16f73824799dd64654fb54dea8c0c2/box-decoration-break-block.png|A screenshot of the rendering of the block element used in the examples without any fragmentation.]]

Fragmenting the above block into three columns results in:

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8183/584309b0158ebda8e5cac77b3ff8ff27/box-decoration-break-block-slice.png|A screenshot of the rendering of the fragmented block used in the examples styled with box-decoration-break:slice.]]

Note that stacking these pieces vertically will result in the non-fragmented rendering.

Now, the same example but styled with box-decoration-break: clone results in:

[[File:../../../../../media.prod.mdn.mozit.cloud/attachments/2014/07/12/8185/93260b044308b14e9f3ea5a2bc409f66/box-decoration-break-block-clone.png|A screenshot of the rendering of the fragmented block used in the examples 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.

Specifications

Specification Status Comment
CSS Fragmentation Module Level 3The definition of 'box-decoration-break' in that specification. Candidate Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
box-decoration-break

Chrome Full support 22

Prefixed' Notes'

Full support 22

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Edge Full support 79

Prefixed' Notes'

Full support 79

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Firefox Full support 32


Full support 32


No support 1 — 32

Alternate Name'

Alternate Name' Uses the non-standard name: -moz-background-inline-policy

IE

No support No

Opera Full support 15

Prefixed'

Full support 15

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit- No support 11.5 — 15


Safari Full support 6.1

Prefixed' Notes'

Full support 6.1

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

WebView Android Full support ≤37

Prefixed' Notes'

Full support ≤37

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Chrome Android Full support 18

Prefixed' Notes'

Full support 18

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Firefox Android Full support 32


Full support 32


No support 4 — 32

Alternate Name'

Alternate Name' Uses the non-standard name: -moz-background-inline-policy

Opera Android Full support 14

Prefixed'

Full support 14

Prefixed'

Prefixed' Implemented with the vendor prefix: -webkit- No support 11.5 — 14


Safari iOS Full support 7

Prefixed' Notes'

Full support 7

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Samsung Internet Android Full support 1.0

Prefixed' Notes'

Full support 1.0

Prefixed' Notes'

Prefixed' Implemented with the vendor prefix: -webkit- Notes' This property is only supported for inline elements.

Legend

Full support  
Full support
No support  
No support
See implementation notes.'
See implementation notes.
Uses a non-standard name.'
Uses a non-standard name.
Requires a vendor prefix or different name for use.'
Requires a vendor prefix or different name for use.


See also