sodcalculator

10 Tech How-To

CSS Blend Modes: How to Blend Images & Colors

Guide 10-54179 · Updated · Step by step

CSS blend modes let you mix the pixels of two or more layers — like an image and a background color — using the same math that photo editors use. You apply them with the mix-blend-mode property (for elements) or background-blend-mode (for backgrounds). This guide explains the modes, how they work, and how to combine them with practical examples.

What Are Blend Modes and Where Do They Come From?

Blend modes originated in image editing software like Photoshop. They define how the color of one layer (the “source”) combines with the color of the layer beneath it (the “backdrop”). CSS adopted these same formulas in the Compositing and Blending specification, giving web designers a way to create rich visual effects without pre-processed images.

The two CSS properties you’ll use are:

  • mix-blend-mode — blends an HTML element (like an <img> or a <div>) with everything behind it.
  • background-blend-mode — blends multiple background layers (images and colors) on a single element.

Both accept the same set of keyword values: normal, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color, and luminosity.

How the Math Works: Normal, Multiply, Screen, Overlay

Each blend mode applies a formula to the red, green, and blue channels of the source and backdrop colors. The result becomes the new pixel color. Here are the core ones:

  • Normal — the source simply replaces the backdrop (no blending).
  • Multiply — multiplies the channel values (0 to 1). Result is always darker. White becomes neutral; black stays black.
  • Screen — inverts, multiplies, then inverts. Result is always lighter. Black becomes neutral; white stays white.
  • Overlay — combines multiply and screen: multiplies where the backdrop is dark, screens where it’s light. Increases contrast.

For example, if you put a semi-transparent red rectangle (rgba(255,0,0,0.5)) over a blue image with mix-blend-mode: multiply, the red channel stays high while the blue channel is multiplied down, producing a dark purple tint. The exact result depends on the pixel values of both layers.

How to Use mix-blend-mode on an Image

The most common use is blending an image with a solid color or another image. Here’s a simple setup:

  1. Create a container <div> with a background color (the backdrop).
  2. Place an <img> inside it.
  3. Apply mix-blend-mode: multiply to the image.
<div style="background-color: #4a90d9;">
  <img src="photo.jpg" style="mix-blend-mode: multiply; width: 100%;">
</div>

In this example, the blue background shows through the image’s lighter areas, while darker areas of the photo remain visible. This effect is often used for duotone-style headers or text overlays.

How to Use background-blend-mode for Layered Backgrounds

When you want to blend a background image with a background color, use background-blend-mode. The order of layers matters: the first layer listed is on top.

div {
  background-image: url("pattern.png");
  background-color: #ff8800;
  background-blend-mode: multiply;
}

You can also blend two images:

div {
  background-image: url("texture.jpg"), url("photo.jpg");
  background-blend-mode: overlay;
}

Here the texture is on top and blends with the photo below. This is a lightweight way to add grain, color casts, or lighting effects without editing the files.

Choosing the Right Blend Mode for Your Effect

Different modes produce very different results. Here’s a quick guide:

  • Multiply — darkens; good for shadows, text over images, or removing white backgrounds.
  • Screen — lightens; good for glows, highlights, or removing black backgrounds.
  • Overlay / Soft-light / Hard-light — increase contrast; good for textures and overlays that should preserve detail.
  • Difference / Exclusion — create inverted, high-contrast effects; often used for artistic looks.
  • Color / Hue / Saturation / Luminosity — blend only certain aspects of the color; useful for recoloring or matching tones.

Experiment by changing the mode and the opacity of the source layer. The same image and color combination can look completely different with a single keyword change.

Common Problems and Browser Support

Blend modes are well-supported in all modern browsers, but there are a few gotchas:

  • Isolation — by default, an element with mix-blend-mode blends with everything behind it, including the page background. To limit blending to a specific container, add isolation: isolate to that container. This creates a new stacking context.
  • Performance — heavy use of blend modes on large images can slow down rendering, especially on low-end mobile devices. Use them sparingly and test.
  • No blending with the page background — if the element has no backdrop (e.g., it’s at the root), the blend may not show any effect. Ensure there’s something behind it.
  • Opacity — blending works on the rendered pixel colors, so an element’s own opacity affects the result. A semi-transparent source will blend differently than a fully opaque one.

Blend Modes vs. CSS Filters

Filters like grayscale() or brightness() change a single layer’s appearance. Blend modes combine two layers. They’re often used together: apply a filter to the image first, then blend it with a color. For example, you could desaturate an image and then multiply it with a brand color to create a consistent monochrome look across a site.

Frequently Asked Questions

Can I blend an image with a gradient?

Yes. You can set a gradient as a background layer and blend it with an image using background-blend-mode. For instance, background-image: linear-gradient(...), url(...) with background-blend-mode: multiply will apply the gradient’s color over the photo.

Why isn’t my mix-blend-mode working?

Check that the element has something behind it to blend with. If it’s the only child of a body with a white background, the effect may be invisible. Also verify that the parent doesn’t have isolation: isolate unless you intend to limit the blending. Finally, make sure the element isn’t using position: fixed in a way that creates a new stacking context.

Does mix-blend-mode work on text?

Yes. You can apply it to any element, including text. A common trick is to blend text with a background image using mix-blend-mode: multiply or screen to create a cutout or overlay effect. The text must be a separate element from the background.

What’s the difference between mix-blend-mode and background-blend-mode?

mix-blend-mode blends an entire element (including its children) with the content behind it. background-blend-mode blends only the background layers of the same element — it never affects the element’s content or what’s behind it.

Are blend modes supported in all browsers?

Yes, for current versions of Chrome, Firefox, Safari, and Edge. Internet Explorer does not support them, but it’s no longer widely used. For older browsers, the effect simply won’t apply; the content remains visible but unblended.

Can I animate blend modes?

You can animate the opacity of the blended element, but the blend mode itself is not animatable. You can transition between different blend modes by using a CSS animation that changes the keyword, but the change will be instant, not gradual.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →