Fragment Decorations: Slice One Box or Clone Each Part
2026-11-21

Fragment Decorations: Slice One Box or Clone Each Part

Fragment Decorations determine how a decorated box is painted when layout breaks it into separate pieces. A highlighted inline can wrap onto another line, leaving more than one fragment of the same element. box-decoration-break chooses whether the decoration behaves like one unbroken box that was sliced or whether each fragment receives an independent set of decorations.

Begin with one element and two given fragments

The MDN property reference describes slice and clone as two rendering models. Consider an original teaching inline that has already broken into a first and second line fragment in a left-to-right setting. The example assumes those breaks are known; it does not attempt to reproduce a browser's complete line-breaking algorithm.

Both fragments still come from the same element. Choosing clone does not duplicate the source text, insert another document node or turn the two fragments into independently authored spans. It changes how the box's decoration is assigned to its fragments. Keeping document structure and painting behavior separate avoids reading the word clone as an instruction to copy content.

For the illustration, margins are zero and the decorations are a border, padding and a small nonrepeating background mark near the beginning. Those explicit choices let broken-edge behavior and background restart be discussed without adding unrelated margin or page-layout effects. The drawings are conceptual and contain no browser screenshot.

Slicefirstfragmentrightedgecutandsecondleftedgecutlacknewborders;cloneallindependentlywrapped.
Conceptual given breaks; no DOM duplication or browser layout. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Slicing does not add a new border at the break

The CSS Fragmentation specification defines slice as the effect of rendering without breaks and then slicing. No new border or padding is inserted at a broken edge, and no box shadow is drawn at that edge. Decorations such as backgrounds and radii follow the theoretical whole-box geometry rather than restarting as independent boxes.

In the simplified left-to-right example, the first fragment's line-end break and the second fragment's line-start break are the newly exposed cut edges. They do not acquire complete independent end decorations merely because the fragments appear on separate lines. The actual broken side depends on the applicable inline progression direction, so the diagram explicitly labels its direction assumption.

Cloning wraps each fragment independently

With clone, each fragment is independently wrapped with its border, padding and margin, subject to the specification's fragmentation rules. Border radii, border images and shadows apply independently too. In the two-fragment illustration, both pieces therefore receive their own beginning and end decoration rather than sharing only the original box's exterior ends.

This is a rule about fragment decoration, not a promise that changing the property can never influence surrounding geometry. Added fragment padding and borders can matter to layout. Since the teaching diagram starts with given fragments, it should not be used to claim that the exact same text will always break at identical positions before and after a real style change.

Onecontinuousstripmarknearorigin slice laterportiondoesnotrestart whilecloneeachoriginrestarts.
No-repeat does not limit all fragments to one occurrence. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

A nonrepeating background can appear in every cloned fragment

The specification states that backgrounds are drawn independently under clone. A background image with no-repeat can consequently appear once in each fragment. No-repeat prevents tiling within the relevant background area; it does not force all fragments of an element to share one single occurrence when their background areas are cloned.

Under slice, background painting instead follows a composite arrangement of fragments in visual order. In a simple teaching strip with equal given fragments, the second fragment can show a later portion of the same background. That model explains continuity without claiming that every fragmented background uses a naive source-text order or identical dimensions.

The specification includes additional rules when fragment dimensions differ and when breaks occur across columns or pages. The original diagrams intentionally stay with one uncomplicated inline case. This scope keeps the comparison accurate: they show the difference between independent restart and whole-box continuity, rather than pretending to be a complete renderer for every fragmentation context.

Review broken edges and background origins separately

A useful review first marks which edges were created by breaks, then asks whether new border and padding wrap those edges. It separately identifies whether each fragment restarts its background. An element can use one property value consistently while those two visible consequences appear in different places in the drawing.

The comparison should also retain the existing background-repeat setting. Seeing the mark twice under clone does not require changing that setting to repeat. Each independent fragment can have one nonrepeating instance. Counting marks without recording the number of background areas would therefore describe the visible result while missing the cause of the repetition.

The technical learning collection and equipment software notes offer related interface context. All fragments and marks here are original conceptual artwork. They explain decoration rules, with no claim that document nodes were duplicated, that font measurements were taken or that a particular production page's wrapping and browser support were tested.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我