CSS Reference ยท Colors and Backgrounds
The mix-blend-mode property
Reference for the CSS mix-blend-mode property: blend an element with the content behind it using multiply, screen, overlay, difference and more.
The mix-blend-mode property decides how an element's pixels combine with the pixels painted behind it, the same idea as layer blend modes in an image editor. With normal the element simply covers what is behind it. With multiply, screen, difference and the others, the colors are calculated from both layers.
It blends with the element's backdrop: whatever is painted beneath it within the same stacking context. To keep a blend from reaching further back, wrap the group in an element with isolation: isolate.
.overlay { mix-blend-mode: multiply; }
Try it
Each red circle sits over a yellow and a blue half. Watch how every mode produces a different color on each half.
White text with difference inverts whatever is behind it, so it reads on both the dark and the light half.
Syntax
mix-blend-mode: <blend-mode> | plus-darker | plus-lighter /* <blend-mode>: normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity */
- Initial value:
normal - Applies to: all elements
- Inherited: no
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
normal |
No blending; the element paints over its backdrop. |
multiply |
Multiplies the colors. The result is always as dark or darker; white has no effect. |
screen |
The opposite of multiply: the result is as light or lighter; black has no effect. |
overlay |
Multiplies dark areas of the backdrop and screens light ones, increasing contrast. |
darken / lighten |
Keeps the darker or lighter value of each color channel. |
color-dodge / color-burn |
Brightens or darkens the backdrop based on the element's color, with strong effects. |
hard-light / soft-light |
Like overlay, but driven by the element's colors. soft-light is gentler. |
difference / exclusion |
Subtracts one color from the other. exclusion is lower in contrast. |
hue, saturation, color, luminosity |
Combine the hue, saturation, both, or the brightness of the element with the rest from the backdrop. |
plus-darker, plus-lighter |
Additive modes for specialized effects; not widely supported. |
Usage notes
- Creates a stacking context. Any value other than
normalmakes the element form its own stacking context, which can change howz-indexbehaves for it and its children. - Use
isolation: isolateon a wrapper to limit what the element blends with. Without it, an element may blend with something far behind it, such as the page background. Seeisolation. - Blends the whole element, including its children and background. To blend only background layers inside one element, use
background-blend-mode. - Transparent backdrops matter. If nothing opaque is behind the element, the blend has nothing to work with and looks like
normal. Give the stage a background. - Performance. Blending forces compositing work. A few blended elements are fine; large animated areas can be costly on low-end devices.
- Accessibility. The resulting colors change with the backdrop, so contrast is hard to guarantee. Do not rely on blending alone for essential text.
Browser support
The standard blend modes are supported in all current major browsers; plus-darker and plus-lighter have narrower support, so check a compatibility table before using them.
Related
background-blend-modeโ blends an element's own background layersisolationโ contains blendingopacityโ plain transparencyfilterโ other graphical effects- Lesson: Blend Modes