Modern web typography and editorial design frequently employ inline text highlights, pill-shaped tags, rounded background markers, and decorative gradients behind running prose. However, when an inline element (such as a styled <span>, <mark>, or <a> tag) breaks across multiple lines at the edge of a paragraph or viewport, browsers traditionally treat the element as a single continuous box sliced into fragments. Under default browser behaviour, the background and border-radius render cleanly only at the start of the first line and the end of the last line, while the broken intermediate edges appear abruptly sliced, losing padding, borders, and rounded corners.
Through the CSS Fragmentation Module Level 3 property box-decoration-break (and its WebKit vendor prefix -webkit-box-decoration-break), frontend developers can control whether fragmented inline boxes are abruptly sliced or independently cloned with full borders, padding, and rounded geometry on every wrapped line. Safari was one of the earliest browsers to support this styling primitive via WebKit. This guide explains how box-decoration-break functions in WebKit, how to inspect and edit multiline text fragments in Safari Web Inspector, and how to create clean, responsive typography highlights across mobile and desktop viewports.
Understanding box-decoration-break: slice vs clone
The box-decoration-break property specifies how background, padding, border, border-image, box-shadow, clip-path, and margin declarations render when an element fragments across lines, columns, or pages. It supports two primary values:
slice(Default): The element is styled as if it were a single unbroken box before fragmentation occurred. When the box wraps onto subsequent lines, the internal breaks are sliced open. Intermediate line fragments display no left or right padding, no rounded border-radius on the broken edges, and no internal box shadows.clone: Each line box fragment is treated as an independent visual box. Every individual line fragment receives its own complete set of borders, rounded border radii, horizontal padding, and box shadows, wrapping around the text gracefully.
WebKit historically introduced this feature under the vendor prefix -webkit-box-decoration-break. In modern Safari on macOS, iOS, and iPadOS, both standard syntax and the WebKit prefix are supported. However, because older versions of Safari and Chrome require the prefix, best practice dictates declaring both variants in CSS stylesheets.
Enabling and Opening Safari Web Inspector
Before inspecting inline text fragments, verify that Safari’s developer tools are active:
- Open Safari on macOS.
- Navigate to Safari > Settings (or press
Cmd + ,) and select the Advanced tab. - Check the box labelled “Show features for web developers”.
- Navigate to your web page featuring multiline text highlights, right-click the highlighted inline text, and select Inspect Element.
Safari Web Inspector will dock to the screen, highlighting the selected inline element in the DOM tree while displaying computed styles and matched CSS rules in the Styles panel.
Inspecting box-decoration-break in the Styles Sidebar
Select the styled inline element (e.g. .text-highlight) in the DOM tree. Locate the matching rule definition in the right-hand Styles sidebar:
.text-highlight {
background: linear-gradient(135deg, #6366f1, #a855f7);
color: #ffffff;
padding: 4px 10px;
border-radius: 8px;
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
}
When reviewing this rule in Safari Web Inspector:
- Vendor Prefix Verification: Check both
box-decoration-breakand-webkit-box-decoration-break. In Safari, ensure neither declaration has a strikethrough error line indicating invalid property syntax. - Computed Property Tab: Switch to the Computed tab in the sidebar and search for
box-decoration-break. Confirm that the calculated value resolves toclone. If it displaysslice, an overriding stylesheet or CSS reset is negating your styling rule.
Testing slice vs clone Live in Safari Web Inspector
Safari Web Inspector allows live value switching so developers can evaluate typography presentation without altering production code.
Toggling Between slice and clone
In the Styles panel, double-click the value clone and change it to slice:
-webkit-box-decoration-break: slice;
box-decoration-break: slice;
Notice the immediate visual change in the Safari viewport:
- Under
slice, the first line loses its right-side rounded corner, and the second line loses its left-side rounded corner. The background appears sliced down the middle like an unsealed cylinder. - Switch the value back to
clone. Immediately, every wrapped line displays perfectly rounded corners (border-radius: 8px) and balanced left and right padding (padding: 4px 10px).
Testing Gradient Flow Across Cloned Fragments
When using CSS linear gradients behind inline text, box-decoration-break: clone recalculates the gradient coordinates for each line box individually:
/* Gradient recalculates across each line */
background: linear-gradient(to right, #3b82f6, #ec4899);
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
In Safari Web Inspector, edit gradient stops or angle values in real time to ensure colour transitions remain harmonious across multiple wrapped lines.
Verifying Responsive Line Wrapping and Breakpoints
Inline highlights often fit on a single line on desktop screens but break across two or three lines on smaller mobile displays. Test responsive behaviour using Safari’s built-in Responsive Design Mode:
- From Safari’s top menu bar, select Develop > Enter Responsive Design Mode (or press
Cmd + Option + R). - Resize the viewport handle or choose an iPhone preset (such as iPhone 15 Pro).
- Observe how the text breaks as the container narrows.
- If lines wrap too tightly, adjust the inline element’s
line-height(e.g.line-height: 1.8) in Web Inspector’s Styles pane to prevent cloned vertical paddings and box shadows from overlapping adjacent text lines above or below.
Troubleshooting Common box-decoration-break Gotchas in WebKit
When styling multiline inline elements in Safari, check for these frequent configuration pitfalls:
- Missing -webkit- Prefix: While modern Safari builds support standard un-prefixed syntax, older WebKit engines and embedded iOS WKWebView instances require
-webkit-box-decoration-break. Always provide both declarations:-webkit-box-decoration-break: clone; box-decoration-break: clone; - Display Block Incompatibility:
box-decoration-break: cloneis designed for inline formatting contexts (display: inline). If the styled element is changed todisplay: blockordisplay: inline-block, the entire element wraps as a single rigid rectangular block rather than breaking into multi-line fragments, rendering the property inactive. - Line Overlap with Box Shadows: When
box-shadowis applied to cloned inline boxes, each line casts an independent shadow. Ensure adequateline-heightis defined on parent paragraphs to prevent shadows from clipping into preceding text lines.