Educational guide to mix-blend-mode
How to control blending between layers
Understand what participates in mix-blend-mode, how isolation limits it, and when to keep the effect separate from text. These scenes use native CSS and are independent of the playground.
Mental model
Blending needs two inputs: the element’s pixels and the backdrop already painted behind it, within its compositing group.
- 1. Painted backdrop
The container background and earlier overlapping layers.
- 2. Blending element
Its content combines with that backdrop using the chosen mode.
- 3. Composited result
Blending and alpha determine the visible color.
The container matters too
The backdrop is more than background-color. It can include an image, a gradient, and siblings painted earlier. A transparent container can let outside content participate; an isolated group defines the boundary.
The painted group blends
The initial value is normal and the property is not inherited. Applying it to a container blends its painted output, including descendants. Setting normal on a child does not remove it from the effect applied to the group.
Use mix-blend-mode to combine an element with what is behind it. To blend only the background layers of one box, use background-blend-mode. To transform the element’s pixels with functions such as grayscale(), use filter.
Choosing a blend mode
Write a single keyword, not a chain of functions. First compare normal and the effect over light and dark areas.
multiply tends to darken: white leaves the backdrop unchanged and black turns it black. screen tends to lighten: black leaves the backdrop unchanged and white turns it white. difference with white inverts the backdrop channels, but does not guarantee readable text.
One circle, four modes, and the same backdrop
normal
multiply
screen
difference
Contrast and lighting
overlay · hard-light · soft-lightoverlay chooses between darkening and lightening based on the backdrop; hard-light chooses based on the element. Swapping the layers can change the result. soft-light produces a gentler effect.
Comparing channels
darken · lighten · color-burn · color-dodgedarken and lighten choose the darker or lighter channels. color-burn and color-dodge produce stronger changes; check areas where detail disappears.
Color components
hue · saturation · color · luminosityhue takes the element’s hue; saturation takes its saturation; color takes both. They retain the backdrop’s luminosity. luminosity takes the element’s luminosity and retains the backdrop’s hue and saturation.
Difference and addition
exclusion · plus-lighterexclusion resembles difference with less contrast. plus-lighter adds contributions and clamps the result; it can serve fades with complementary opacities. It is not equivalent to screen or a general brightness adjustment.
Blending and transparency are separate operations: with partial alpha, the visible backdrop also contributes. opacity on a parent composites the whole group and creates a stacking context. To adjust only the artwork, change its color alpha or its own opacity and check the result.
Limiting the backdrop with isolation
Isolate the composition’s container, keeping the layers that should blend inside it.
isolation: isolate creates a group with a transparent initial backdrop: its children do not blend with content outside it. Layers and backgrounds painted inside still participate. In this comparison, the inner group is transparent and contains a single circle.
The same circle in a transparent group
Inner group: auto
Inner group: isolate
auto does not remove other contexts. If the container already creates one through transform, filter, opacity below 1, or certain z-index combinations, changing isolation may produce no visible difference. Isolation neither clips the box nor fixes its size.
Stacking and paint order
An element can only blend with layers painted behind it. An opaque layer painted later can cover the result.
A mix-blend-mode value other than normal creates a stacking context. Its children’s z-index values are resolved within that context; a large number cannot make them escape above every element on the page.
The same geometry, a different order
Blue stripe behind
Blue stripe in front
position: relative alone, with z-index: auto, does not create a stacking context. Check ancestors before changing numbers: a new context can change the available backdrop. Avoid adding transform or will-change without a specific need.
Practical example: decoration and text
An isolated composition limits the effect to decorative artwork; the message retains its colors and an opaque surface.
This recipe applies multiply only to the circle and reuses the lab’s declarations for that element. The paragraph is its sibling, has its own background, and stays outside the circle’s blended group. Keep this separation when replacing the shape with an image.
Decorative blending with a readable message
The circle is decorative and uses aria-hidden. An informative image needs a text alternative. Check contrast on the final result in both themes and with other backdrops: difference is not an automatic contrast system for links, controls, or essential text.
Common pitfalls
Check the actual backdrop, the blended group, and the surrounding layers.
multiply seems to do nothing
- Expected result
- The element changes as it crosses the backdrop.
- Cause
- The backdrop is white, there is no overlap, or an isolated group is empty behind the element. White is neutral with multiply.
- Solution
- Try a colored stripe within the same group. Use normal as a reference and check geometry before blaming support.
Blending depends on the page background
- Expected result
- The composition keeps a local scope.
- Cause
- A transparent container with isolation: auto lets the outside backdrop participate if no other context limits it.
- Solution
- Set isolation: isolate on the container that groups the layers, and define the desired backdrop inside it.
The text changes color too
- Expected result
- Only the decorative image blends.
- Cause
- The mode is on the parent, which blends its entire group. normal on the child text cannot undo the parent’s operation.
- Solution
- Move mix-blend-mode to the decoration. Keep text as a sibling with colors and a background whose contrast you have checked.
A huge z-index does not fix blending
- Expected result
- The layer participates in the intended composition.
- Cause
- An ancestor creates another context, or a later layer covers the element. The index only orders within the corresponding context.
- Solution
- Inspect the context tree and paint order. Group the layers that should blend and isolate that group.
Background images do not blend with each other
- Expected result
- background-image layers combine within one box.
- Cause
- mix-blend-mode blends the box with its surroundings, not its backgrounds with each other.
- Solution
- Use background-blend-mode for those layers and reserve mix-blend-mode for overlapping elements.
Support and compatibility
Distinguish support for the property, the specific value, and the actual composition.
mix-blend-mode and isolation are Baseline Widely Available. The playground includes plus-lighter, whose support arrived in different versions from the classic modes. Check compatibility for the value you plan to reuse.
Documentation also lists plus-darker; it is not among this lab’s controls. A positive CSS.supports result only confirms that the browser accepts the syntax: it does not certify the output, contrast, or every layer combination.
If the browser ignores the mode, normal compositing remains. The recipe keeps text readable without the effect. In forced colors, these examples disable decorative blending and use system colors; labels and captions retain the explanation. They add no animations.