← Chrome 159 reference · All APIs
v159 · css · enabled by default
Background layer count independence
The computed values of coordinating background-* longhand properties (such as background-position, background-size, background-repeat, background-origin, background-clip, and background-attachment) now keep the exact number of comma-separated values specified by the author instead of repeating or truncating them to match the background-image layer count. Truncation and cyclic repetition apply strictly at used-value time during painting, aligning Chromium with CSS Values and Units Level 4 Appendix A, Firefox, and Safari Technology Preview.
at a glance
why it exists
Prior to Chrome 159, Chromium coupled the computed values of background-* longhand properties to the length of background-image: if an element had one background-image (or the initial value none) and three comma-separated background-position values, getComputedStyle(el).backgroundPosition truncated the list to one item; conversely, if background-image had three layers and background-repeat had one item, Blink expanded the computed list. That diverged from CSS Values 4 Appendix A and Firefox, broke inherited or dynamically toggled background-image layers (where a parent sets multi-layer positions/sizes independently), and broke repeatable-list interpolation in animations. On 2026-03-11 the CSS Working Group resolved in w3c/csswg-drafts#12791 to keep the spec’s computed-value independence rule and align WPT; Chrome 159 ships that catch-up.
Syntax and computed-vs-used value contract
No new CSS properties or value grammars are added. Every coordinating background-* longhand continues to accept a comma-separated list (# multiplier in CSS Backgrounds 3), while background-image remains the coordinating list base property for used-value painting:
/* Coordinating list base property (determines painted layer count) */
background-image: <bg-image>#;
/* Coordinating list longhands (computed list length is preserved independently) */
background-attachment: <attachment>#;
background-clip: <visual-box>#; /* plus text / border-area where supported */
background-origin: <visual-box>#;
background-position: <bg-position>#;
background-position-x: [ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#;
background-position-y: [ center | [ [ top | bottom | y-start | y-end ]? <length-percentage>? ]! ]#;
background-repeat: <repeat-style>#;
background-size: <bg-size>#;
/* Non-list background longhand (always a single color, painted behind all layers) */
background-color: <color>;
“If a coordinating list property has too many values specified, excess values at the end of its list are not used. If a coordinating list property has too few values specified, its value list is repeated to add more used values. The computed values of the coordinating list properties are not affected by such truncation or repetition.”
This contract has four developer-visible behaviors: computed-value list preservation across all coordinating background-* longhands, used-value layer coordination against background-image, background shorthand CSSOM serialization on mismatched list lengths, and repeatable-list animation interpolation.
Computed-value list preservation across background-* longhands
Inputs. Any valid comma-separated list of 1, 2, 3, or N values declared on any coordinating background-* longhand, regardless of how many layers are declared on background-image (including when background-image is omitted and defaults to none, or has multiple none entries such as background-image: none, none, none).
Outputs. getComputedStyle(el) returns the exact number of list items specified on that longhand after normal per-item value computation (for example, converting 0.5em to pixels or keywords like center to 50%), with neither truncation nor cyclic repetition. background-color is not a list-valued property and always computes to a single resolved <color>; background-blend-mode (from CSS Compositing 1) already computes as specified.
| Property & specified value | Chrome < 159 (coupled) | Chrome 159+ (independent) |
|---|---|---|
background-attachment: local (1 item) | Repeated to 3 items (local, local, local) | local (1 item preserved) |
background-clip: content-box, border-box (2 items) | Repeated to 3 items | content-box, border-box (2 items preserved) |
background-origin: content-box, border-box, padding-box, content-box (4 items) | Truncated to 3 items | content-box, border-box, padding-box, content-box (4 items preserved) |
background-position: 12px 13px, 50% 6px, 30px -10px, -7px 8px (4 items) | Truncated to 3 items | All 4 pairs preserved verbatim |
background-position-x: calc(10px - 0.5em), -20%, right, 15% (4 items, font-size: 40px) | Truncated to 3 items | -10px, -20%, 100%, 15% (4 items) |
background-repeat: repeat-y, round no-repeat, repeat-x, repeat (4 items) | Truncated to 3 items | All 4 items preserved |
background-size: auto 1px, 2% 3%, contain, 7px 8px (4 items) | Truncated to 3 items | All 4 items preserved |
Used-value layer coordination during painting
Inputs & algorithm. Visual rendering is unchanged: CSS Backgrounds 3 §2.1 still determines the number of painted background layers solely from the number of comma-separated entries in background-image (where an entry of none still creates a layer slot). For each layer index k from 0 to L − 1 (where L is the length of background-image):
- If a coordinating longhand has more than L computed items, items at index
≥ Lare ignored at used-value time (they remain in the computed value and CSSOM, and become active automatically ifbackground-imagelater gains more layers). - If a coordinating longhand has fewer than L computed items (length M), the used value for layer k cycles through item
k mod M. - The first layer in
background-imagepaints closest to the viewer; subsequent layers paint behind it;background-colorpaints beneath all image layers.
Outputs. Painted pixels are identical to pre-159 Chromium for any static combination of declarations; only computed-value inspection (getComputedStyle()), inheritance (via inherit), shorthand serialization, and list-length animation interpolation change.
background shorthand CSSOM serialization
Inputs & outputs. Per CSS Values 4 Appendix A, the background shorthand represents each layer by combining corresponding items across all coordinating longhands. It can only serialize its longhands when every non-initial coordinating longhand has the same list length:
- If all non-initial coordinating longhands share equal list length (and any omitted longhands hold their initial values), the shorthand can represent the combined layers.
- If any two non-initial coordinating longhands have mismatched list lengths (for example,
background-imagehas 2 layers whilebackground-sizehas 3), the CSSOM representation of thebackgroundshorthand returns the empty string ("").
Note that WPT background-computed.html also tracks open issue w3c/csswg-drafts#418 regarding full computed-value serialization details for the background shorthand itself; reading individual longhands (such as getComputedStyle(el).backgroundSize) is deterministic and unaffected.
Repeatable-list interpolation in animations and transitions
Inputs & outputs. When CSS transitions or Web Animations interpolate background-position or background-size between two keyframes whose list lengths differ (for example, from with 2 items and to with 3 items), the engine repeats each endpoint list to the least common multiple of their lengths (LCM(2, 3) = 6 items) and interpolates item-by-item, regardless of how many layers background-image defines (even when background-image is none, i.e. 1 layer). Because Chrome 159 no longer truncates computed longhand lists to background-image’s length before interpolation, all 6 interpolated items are preserved in getComputedStyle() throughout the animation.
Lifecycle & dynamic updates. Because computed values are independent of background-image, dynamically adding or removing an image in background-image does not mutate the computed values of background-position, background-size, background-repeat, background-origin, background-clip, or background-attachment; only the used-value layer assembly recomputes during layout/paint. Children using background-position: inherit (or other longhand inherit) receive the parent’s full preserved list rather than a list truncated or repeated to the parent’s background-image count.
Errors, migration risks, and feature detection
CSS background longhands never throw JavaScript exceptions on mismatched layer counts, and invalid declarations are dropped at parse time per standard CSS error handling. However, existing scripts written against Chromium < 159 can break silently if they assumed getComputedStyle(el).backgroundPosition.split(",") always had the same length as background-image:
- Do not assume equal computed list lengths: when inspecting layers in JavaScript, derive the active layer count from
backgroundImageand resolve indexi % longhandItems.lengthto match CSS Backgrounds 3 used-value semantics. - Runtime detection: test on a probe element with default
background-image: noneand twobackground-sizevalues (10px 10px, 20px 20px); ifgetComputedStyle(probe).backgroundSizeretains both items (contains a comma), the engine implements layer-count independence. - Fallback for older Chromium / Safari: if identical
getComputedStyle()list lengths are required across Chrome < 159 and stable Safari, explicitly declare matching list lengths onbackground-imageand its coordinating longhands.
Context and exposure
Applies to all CSS stylesheets (document stylesheets, shadow DOM stylesheets, inline style attributes, CSS Typed OM, CSS transitions, and Web Animations) on any renderable element in any browsing context. Requires no secure context, no permission, no user activation, and no JavaScript API opt-in. Not applicable to Web Workers (no DOM styling).
Examples
No interactive demo exists yet on the Chrome Platform Showcase for Chrome 159 (checked 2026-11-24).
Preserving computed longhand lists independently of background-image
<div id="card" class="layered"></div>
<style>
.layered {
/* 1 layer initially (or 3 layers once a class adds gradients) */
background-image: none;
background-position: 12px 13px, 50% 6px, 30px -10px;
background-size: auto 1px, 2% 3%, contain, 7px 8px;
background-repeat: no-repeat;
}
.layered.with-images {
background-image:
linear-gradient(90deg, #0b57d0, transparent),
radial-gradient(circle, #e37400, transparent),
linear-gradient(180deg, #137333, transparent);
}
</style>
<script>
const el = document.getElementById("card");
const cs = getComputedStyle(el);
// Chrome 159+, Firefox, Safari TP 246:
// Preserves all 3 positions and all 4 sizes even while background-image is "none".
console.log(cs.backgroundPosition); // "12px 13px, 50% 6px, 30px -10px"
console.log(cs.backgroundSize); // "auto 1px, 2% 3%, contain, 7px 8px"
console.log(cs.backgroundRepeat); // "no-repeat" (NOT repeated to 3 items)
// Used-value painting when .with-images is added:
// Layer 0 uses (12px 13px, auto 1px, no-repeat)
// Layer 1 uses (50% 6px, 2% 3%, no-repeat)
// Layer 2 uses (30px -10px, contain, no-repeat)
// The 4th background-size item (7px 8px) is unused at paint time but stays in computed style.
el.classList.add("with-images");
</script>
Source: WPT background-computed.html; CSS Backgrounds 3 §2.1.
Shorthand empty-string serialization and feature detection
function supportsIndependentBackgroundLayerCount() {
const probe = document.createElement("div");
probe.style.backgroundImage = "none";
probe.style.backgroundSize = "10px 10px, 20px 20px";
document.body.append(probe);
const independent = getComputedStyle(probe).backgroundSize.includes(",");
probe.remove();
return independent;
}
// Shorthand serialization when non-initial longhands have mismatched list lengths:
const box = document.createElement("div");
box.style.backgroundImage = "none, none";
box.style.backgroundPosition = "0px 0px, 10px 10px, 20px 20px";
// Per CSS Values 4 Appendix A, cannot serialize mismatched lengths into one shorthand list:
console.log(box.style.background); // ""
Source: CSS Values 4 Appendix A; WPT background-size-computed.html.
Mismatched-length background-position animation (LCM repetition)
const anim = document.getElementById("card").animate(
[
{ backgroundPosition: "0px 0px, 80px 0px" }, // 2 items
{ backgroundPosition: "40px 40px, 80px 80px, 0px 80px" } // 3 items
],
{ duration: 1000, fill: "forwards" }
);
// Repeatable-list interpolation expands both lists to LCM(2, 3) = 6 items,
// even when background-image has only 1 layer ("none"):
// At 50%: "20px 20px, 80px 40px, 0px 40px, 60px 20px, 40px 40px, 40px 40px"
Source: WPT background-position-interpolation.html; WPT background-size-interpolation.html.
Browser compatibility
| Browser | Layer-count independence | Evidence / notes | Base background-* (BCD) |
|---|---|---|---|
| Chrome (desktop, Android, WebView, iOS) | 159 | Enabled by default via CSSBackgroundLayerCountIndependence per ChromeStatus API record and runtime_enabled_features.json5 | Chrome 1 / Android 18 |
| Edge | Unknown (Chromium 159) | Chromium-based; inherits Chromium 159 behavior once Edge 159 ships (no separate BCD subfeature) | 12 |
| Firefox | Shipped | Already implemented per spec prior to Chrome 159; cited as the existing spec-compliant engine in w3c/csswg-drafts#12791 (exact first version unrecorded in BCD) | 1 (desktop) / 4 (Android) |
| Safari | TP 246 (stable unknown) | Shipped in Safari Technology Preview 246 (WebKit bug 315771); stable Safari version not yet confirmed in BCD | 1 / iOS 1 |
Security and privacy
Preserving the author-declared list length on computed background-* longhands introduces no new storage, network fetch, permission, cross-origin disclosure, or user-fingerprinting surface: the exposed values are strictly the declarations already supplied by the document’s own stylesheets. ChromeStatus records no security risks and lists security/privacy reviews as Pending (checked 2026-11-24).
Specifications
see also
- MDN —
background-image - MDN —
background - w3c/csswg-drafts#12791 — CSSWG resolution on coordinating list computed values
- w3c/csswg-drafts#7164 — How to handle linked list-valued properties
- WebKit bug 315771 & Safari Technology Preview 246 release notes
- ChromeStatus — Background layer count independence (5144333908049920)