Compositing layers with CSS blend modes
Blend modes calculate an element's final color from its own pixels and the backdrop below them. mix-blend-mode blends an element with content behind it; background-blend-mode combines multiple background layers inside one element.
The result depends on the actual backdrop, so the same declaration can look completely different in another container. Controlled blending therefore begins by defining a local compositing boundary.
Choose mix or background blending
Use background-blend-mode when gradients and images belong to a single surface. Use mix-blend-mode when a child layer, heading, or decorative object should interact with pixels beneath it.
Common modes include multiply for ink-like darkening, screen for lightening, overlay for stronger contrast, and difference for inversion-like effects. Test with the real colors rather than selecting a mode by name alone.
- multiply
- Darkens by multiplying channels; useful for texture and ink effects.
- screen
- Lightens by inverting, multiplying, and inverting again.
- difference
- Uses channel differences; dramatic but sensitive to backdrop changes.
.artwork {
isolation: isolate;
background:
linear-gradient(135deg, #2563eb, #ec4899),
url("portrait.jpg") center / cover;
background-blend-mode: color;
}
.artwork__glow {
mix-blend-mode: screen;
background: radial-gradient(circle, #fff8, transparent 65%);
}Contain blending with isolation
Without a new stacking context, a blending child may interact with backgrounds outside its component. isolation: isolate tells the browser to composite the component as a group and prevents that visual leak.
Apply isolation at the component boundary, not indiscriminately across every child. A clear boundary also makes screenshots and theme changes more predictable.
Animate geometry, not the blend calculation
Moving a blended element changes which backdrop pixels it samples and may force large areas to repaint. Prefer small contained layers, and animate their transform or opacity rather than switching blend modes continuously.
Fixed blended decorations can be especially costly because the entire scrolling backdrop changes beneath them. Measure before using that pattern on long pages.
Keep meaning independent of compositing
Blend results vary across themes, photographs, and browser color pipelines. Do not use them as the only way to show status or preserve text contrast. Provide a stable base color and treat blending as enhancement.
If text itself is blended, test the lightest and darkest supported backdrops. Ordinary text should usually remain outside the effect layer.
Live catalog examples
These production examples use mix-blend-mode. Open any effect to inspect its complete source and experiment in the browser editor.
Browser support
Support notes refer to stable, unprefixed behavior unless a prefix is explicitly listed.
| Feature | Browsers | Note |
|---|---|---|
| mix-blend-mode | All modern browsers | Results depend on stacking contexts and backdrop pixels. |
| background-blend-mode | All modern browsers | One mode can be supplied per background layer. |
| isolation | All modern browsers | Use `isolate` to create a predictable component boundary. |
Common pitfalls
The effect leaks into the page
Add
isolation: isolateto the intended component boundary.The design assumes a white backdrop
Provide a known local background instead of relying on the page behind the component.
A large blended layer is animated
Contain the layer and animate inexpensive geometry; profile scrolling and repainting.
Text contrast is left to the blend mode
Keep essential text on a stable, contrast-tested surface.
Frequently asked questions
- What is the difference between the two blend properties?
- mix-blend-mode blends an element with its backdrop; background-blend-mode combines backgrounds within one element.
- Why does blending change outside the component?
- The component lacks a compositing boundary. Add `isolation: isolate`.
- Which mode creates a duotone?
- A color or luminosity blend combined with a controlled gradient is a common starting point, but the source image matters.
- Are blend modes expensive?
- They can increase compositing and repaint work. Cost grows with area, motion, and backdrop changes.
Related guides
- backdrop-filterFrosted glass with backdrop-filterBlur and adjust the scene behind translucent surfaces without sacrificing contrast, fallback quality, or scrolling performance.
- maskAlpha masking with CSS maskControl visibility per pixel with gradients and images, including soft edges, real cutouts, and reusable monochrome icons.
- conic-gradient()Rings, charts, and highlights with conic-gradientPaint angular color stops for progress rings, segmented charts, rotating glows, and compact procedural patterns.
- ::before / ::afterLayering with ::before and ::afterCreate independent decorative layers with predictable positioning, stacking, clipping, and pointer behavior.
Last updated:
All guides