Blend Modes
The shadows, gradients, and filters you learned about in the core readings all apply effects to a single element or its backdrop. Blend modes do something different: they control how two layers of color combine where they overlap. Instead of painting one layer on top of another and hiding what is underneath, a blend mode mixes the pixel values of both layers together using a mathematical formula. The result can darken, lighten, multiply, screen, or otherwise composite colors in ways that no opacity or filter can replicate.
CSS provides two blend mode properties. mix-blend-mode controls how an entire element blends with whatever sits behind it in the stacking order. background-blend-mode controls how an element's own background layers (images, gradients, colors) blend with each other inside the element. Both accept the same set of blend mode keywords, but they operate at different levels: one is outward facing and one is internal.
How Blend Modes Work
Every blend mode takes two inputs: a source layer (the element or layer on top) and a destination layer (whatever sits underneath). The browser evaluates each pixel independently, combining the source and destination color values through a specific formula. The result replaces the source pixel in the final composite.
The available blend modes fall into a few families based on what they tend to do:
-
Darken family (
darken,multiply,color-burn): The result is always darker than or equal to the original layers. White in the source layer disappears. These are useful for pressing a texture or pattern into a darker background. -
Lighten family (
lighten,screen,color-dodge): The result is always lighter than or equal to the original layers. Black in the source layer disappears. These are useful for projecting light effects or glows onto a background. -
Contrast family (
overlay,soft-light,hard-light): These combine darkening and lightening. Mid-tones shift the most while highlights and shadows are preserved.overlayis the workhorse of this group and the most commonly used blend mode in web design. -
Component family (
hue,saturation,color,luminosity): These replace a specific channel of the destination with the corresponding channel from the source.colorapplies the hue and saturation of the source while keeping the luminosity of the destination, which is how you colorize a grayscale image.
You do not need to memorize every formula. What matters is understanding the families so you can predict roughly what a mode will do before you try it, and then experiment to fine-tune the result.
background-blend-mode
The background-blend-mode property blends an element's background layers with each other. This is particularly powerful when you stack a solid color or gradient on top of a background image. The blend happens entirely inside the element, so it does not affect anything outside it and does not create stacking context issues.
/* Color wash over a photo */
.hero {
background:
oklch(0.45 0.2 260),
url('/images/hero.jpg') center / cover;
background-blend-mode: multiply;
}
In this example, the solid blue color sits on top of the photo in the background stack. The multiply blend mode darkens the image through the blue, producing a rich duotone effect without editing the original photo. Change the color and the entire mood shifts instantly, which is far more flexible than pre-processing images in an editor.
You can also blend a gradient over a photo for directional color effects:
/* Gradient duotone: warm to cool across the image */
.hero {
background:
linear-gradient(to right, oklch(0.5 0.2 30), oklch(0.4 0.2 280)),
url('/images/hero.jpg') center / cover;
background-blend-mode: overlay;
}
The overlay mode preserves the photo's contrast while shifting the color palette along the gradient. The left side takes on a warm tone and the right side shifts cool. This is a single CSS declaration doing work that would otherwise require a round trip to Photoshop.
mix-blend-mode
Where background-blend-mode works inside an element, mix-blend-mode controls how the entire element blends with whatever sits behind it in the page. This includes other elements, background colors, and images. It is more powerful but also more unpredictable because it interacts with the full rendering context.
.overlay-text {
mix-blend-mode: screen;
color: oklch(0.9 0 0);
}
The example above makes white text that lightens whatever sits behind it, creating a projected-light effect. Dark areas of the background stay mostly unchanged while lighter areas glow through the text. This can look striking on photography, but it comes with a serious caution: the text's legibility depends entirely on what is behind it. Move the element, change the background, or scroll the page and the contrast can collapse. Always test mix-blend-mode on text across every context it will appear in, and be prepared to add a fallback like a semi-transparent background behind the text if the blend alone does not guarantee readability.
Blend modes on text are visually exciting but accessibility-dangerous. The contrast ratio between the blended text and the background varies per pixel depending on the content behind it. A blend that looks beautiful over a dark photo may become invisible over a light area of the same photo. If you use mix-blend-mode on text, test it at WCAG AA contrast ratios across the full range of backgrounds it will encounter. When in doubt, use background-blend-mode on the container instead so the text sits on a predictable surface.
Isolation: Controlling the Blend Scope
By default, mix-blend-mode blends with everything below the element in the stacking order, including content you might not expect. If a blended element sits inside a card that sits on top of a colorful background, the blend reaches through the card and interacts with the background. This is what the scaffold outline calls "colors exploding." The result is often garish or broken because the blend was never designed to interact with those layers.
The isolation property fixes this. Setting isolation: isolate on a parent element creates a new stacking context that acts as a boundary for blend modes. The blended child can only interact with siblings inside that context, not with anything outside it:
/* Without isolation: blend leaks through to the page background */
.card {
position: relative;
}
.card .overlay {
mix-blend-mode: multiply;
/* This blends with the card AND whatever is behind the card */
}
/* With isolation: blend stays inside the card */
.card {
isolation: isolate;
}
.card .overlay {
mix-blend-mode: multiply;
/* This only blends with content inside the card */
}
A good rule of thumb: whenever you use mix-blend-mode, set isolation: isolate on the nearest parent that represents the visual boundary you intend. This prevents the blend from leaking into unexpected layers and gives you predictable results. Note that isolation: isolate creates a new stacking context, just like filter and backdrop-filter do.
Guided Demo
This demo composites a color layer over a photo using background-blend-mode. Select different blend modes to see how each one affects the same image. Toggle the color scheme to see how the effect adapts in dark mode:
Blend Mode Comparison
Teaching Video Checklist
When you record your teaching video, make sure your teammates come away understanding these concepts:
-
The difference between
mix-blend-mode(outward, blends with surrounding context) andbackground-blend-mode(inward, blends background layers with each other) - At least three blend modes from different families (darken, lighten, contrast, component) with a live demonstration of each
-
A working hero overlay example using
background-blend-modewith a color or gradient over a photo -
Why
mix-blend-modeon text is risky for accessibility and when to usebackground-blend-modeinstead -
What
isolation: isolatedoes, why it is necessary, and a demonstration of the "colors explode" problem it solves
Start with a single custom property as your overlay color, demonstrate background-blend-mode on a hero image, then show what happens when you use mix-blend-mode without isolation and how adding isolation: isolate fixes it.
Resources
- MDN: mix-blend-mode — Full reference with visual examples for every blend mode keyword
- MDN: background-blend-mode — Reference for blending background layers within a single element
- MDN: isolation — How to create stacking contexts that contain blend mode effects
- CSS-Tricks: Basics of CSS Blend Modes — Practical walkthrough with Photoshop comparisons and use cases
- web.dev: Blending Modes — Visual guide to each mode with interactive examples