Skip to content

CSS Blend Modes: The Art of Layered Visuals ​

CSS Blend Modes: The Art of Layered Visuals

Understanding Blend Modes ​

If you've used Photoshop or other image editing software, you're surely familiar with "layer blend modes." When two layers overlap, the upper layer doesn't always completely obscure the lower one; instead, they can "blend" through different algorithms, creating various visual effects. CSS Blend Modes bring this capability to the web.

Imagine you have two slides: one with a red circle, the other with a blue square. If you overlay them on a projector, depending on the material (transparent film, colored glass, mirror surface, etc.), the overlapping area will produce different visual effects: perhaps purple, perhaps brighter blue, or perhaps complex textures. CSS Blend Modes allow us to precisely control this "overlay effect."

CSS provides two main properties to control blending:

  • mix-blend-mode: Controls how an element blends with its parent and sibling content
  • background-blend-mode: Controls blending between multiple background layers of an element or between background images and colors

mix-blend-mode: Element Blending ​

mix-blend-mode defines how an element blends with the content of its parent element and sibling elements.

Basic Syntax ​

css
.element {
  mix-blend-mode: normal; /* Default, no blending */
  mix-blend-mode: multiply; /* Multiply */
  mix-blend-mode: screen; /* Screen */
  mix-blend-mode: overlay; /* Overlay */
  /* ...and many more modes */
}

Core Blend Modes Detailed ​

normal - Normal Mode ​

Default value, no blending, upper layer completely obscures lower layer:

css
.normal {
  mix-blend-mode: normal;
}

multiply - Multiply ​

Multiplies the color values of the upper and lower layers, result is always darker. Similar to overlapping two slides:

css
.multiply {
  mix-blend-mode: multiply;
}

Features:

  • White becomes transparent (white × any color = that color)
  • Black stays black (black × any color = black)
  • Other colors become darker

Practical scenario - Text融入 background:

html
<div class="hero">
  <h1 class="blend-title">Amazing Design</h1>
</div>
css
.hero {
  background: url("colorful-bg.jpg");
  background-size: cover;
  padding: 100px 0;
}

.blend-title {
  font-size: 120px;
  font-weight: bold;
  color: white;
  mix-blend-mode: multiply;
  /* White text blends with background through multiply,
     presenting background colors while maintaining text shape */
}

screen - Screen ​

Opposite of multiply, multiplies inverted color values then inverts back, result is always lighter. Similar to projector light overlapping:

css
.screen {
  mix-blend-mode: screen;
}

Features:

  • Black becomes transparent (black + any color = that color)
  • White stays white
  • Other colors become lighter

Practical scenario - Glow effect:

css
.glow-effect {
  position: relative;
}

.glow-effect::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
  mix-blend-mode: screen;
  pointer-events: none;
}

overlay - Overlay ​

Combines multiply and screen: dark areas become darker, light areas become lighter, mid-tones stay the same. Increases contrast:

css
.overlay {
  mix-blend-mode: overlay;
}

Practical scenario - Texture overlay:

css
.textured-card {
  background-color: #3498db;
  position: relative;
}

.textured-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("texture.png");
  mix-blend-mode: overlay;
  opacity: 0.3;
}

darken - Darken ​

Compares each color channel of upper and lower layers, choosing the darker value:

css
.darken {
  mix-blend-mode: darken;
}

lighten - Lighten ​

Opposite of darken, chooses the brighter value:

css
.lighten {
  mix-blend-mode: lighten;
}

color-dodge - Color Dodge ​

Makes bright colors brighter, creating high-contrast effects:

css
.color-dodge {
  mix-blend-mode: color-dodge;
}

Practical scenario - Neon light effect:

css
.neon-text {
  color: #ff00ff;
  text-shadow: 0 0 20px currentColor;
  mix-blend-mode: color-dodge;
}

color-burn - Color Burn ​

Makes dark colors darker, increases saturation:

css
.color-burn {
  mix-blend-mode: color-burn;
}

difference - Difference ​

Calculates the difference between upper and lower layer colors, creating inversion effects:

css
.difference {
  mix-blend-mode: difference;
}

Practical scenario - Always visible cursor or highlight:

css
.cursor-highlight {
  position: absolute;
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  mix-blend-mode: difference;
  pointer-events: none;
}

No matter the background color, this highlight remains clearly visible.

exclusion - Exclusion ​

Similar to difference but with lower contrast, more subtle effect:

css
.exclusion {
  mix-blend-mode: exclusion;
}

hue - Hue ​

Keeps lower layer's lightness and saturation, uses upper layer's hue:

css
.hue {
  mix-blend-mode: hue;
}

Practical scenario - Monochrome color images:

css
.colorize {
  position: relative;
}

.colorize::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #ff6b6b; /* Desired color */
  mix-blend-mode: hue;
}

saturation - Saturation ​

Keeps lower layer's lightness and hue, uses upper layer's saturation:

css
.saturation {
  mix-blend-mode: saturation;
}

color - Color ​

Keeps lower layer's lightness, uses upper layer's hue and saturation:

css
.color {
  mix-blend-mode: color;
}

luminosity - Luminosity ​

Keeps lower layer's hue and saturation, uses upper layer's lightness:

css
.luminosity {
  mix-blend-mode: luminosity;
}

background-blend-mode: Background Blending ​

background-blend-mode controls blending between an element's multiple background images, or between background images and colors.

Basic Usage ​

css
.element {
  background-image: url("image1.jpg"), url("image2.jpg");
  background-blend-mode: multiply;
}

Practical: Creative Background Effects ​

Duotone Effect ​

css
.duotone {
  background-image: linear-gradient(to right, #ff6b6b, #4ecdc4),
    url("portrait.jpg");
  background-blend-mode: multiply;
  background-size: cover;
  background-position: center;
}

This creates an effect similar to Spotify album covers.

Gradient Overlay ​

css
.gradient-overlay {
  background-image: linear-gradient(
      135deg,
      rgba(52, 152, 219, 0.8),
      rgba(142, 68, 173, 0.8)
    ),
    url("background.jpg");
  background-blend-mode: overlay;
  background-size: cover;
}

Texture Blending ​

css
.textured-bg {
  background-color: #2c3e50;
  background-image: url("paper-texture.png");
  background-blend-mode: multiply;
}

Multiple Blending ​

Different blend modes can be specified for each background layer:

css
.complex-blend {
  background-image: linear-gradient(45deg, rgba(255, 0, 0, 0.3), transparent),
    url("texture.png"), url("photo.jpg");
  background-blend-mode: screen, overlay;
  /* First gradient uses screen, texture uses overlay, photo as base */
}

Practical Application Cases ​

Case 1: Dynamic Text Effects ​

Create text that changes color with the background:

html
<div class="dynamic-bg">
  <h1 class="blend-text">Dynamic Text</h1>
</div>
css
.dynamic-bg {
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  padding: 100px;
  animation: gradient-shift 5s ease infinite;
}

@keyframes gradient-shift {
  0%,
  100% {
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  }
  50% {
    background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
  }
}

.blend-text {
  font-size: 100px;
  font-weight: bold;
  color: white;
  mix-blend-mode: difference;
  /* Text color inverts with background, always visible and dynamically changing */
}

Case 2: Image Mask Effect ​

html
<div class="image-mask">
  <img src="photo.jpg" alt="Photo" />
  <div class="mask"></div>
</div>
css
.image-mask {
  position: relative;
  width: 500px;
  height: 500px;
}

.image-mask img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 70%
  );
  background-size: 200% 200%;
  mix-blend-mode: overlay;
  animation: shine 3s infinite;
}

@keyframes shine {
  from {
    background-position: -100% -100%;
  }
  to {
    background-position: 200% 200%;
  }
}

This creates a moving shine effect over the image.

Case 3: Hover Blending Effects ​

css
.gallery-item {
  position: relative;
  overflow: hidden;
}

.gallery-item img {
  transition: transform 0.5s;
}

.gallery-item:hover img {
  transform: scale(1.1);
}

.gallery-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
  opacity: 0;
  mix-blend-mode: color;
  transition: opacity 0.5s;
  pointer-events: none;
}

.gallery-item:hover::before {
  opacity: 0.8;
}

On hover, images get colorized, creating movie poster-like effects.

Case 4: Brand Colorization ​

Colorize black and white logos to brand colors:

css
.logo-container {
  position: relative;
  background-color: #3498db; /* Brand color */
}

.logo-container img {
  /* Assume logo is black icon */
  mix-blend-mode: lighten;
  /* Black parts will show brand color, white background stays white */
}

Case 5: Text Cutout Effect ​

html
<div class="cutout-text-container">
  <h1 class="cutout-text">HOLLOW</h1>
</div>
css
.cutout-text-container {
  background: url("colorful-bg.jpg") center/cover;
  padding: 100px;
  position: relative;
}

.cutout-text-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background: white;
}

.cutout-text {
  position: relative;
  font-size: 150px;
  font-weight: bold;
  color: black;
  mix-blend-mode: multiply;
  /* Black text lets background show through through multiply,
     creating text cutout effect */
}

Performance Considerations ​

Blend modes trigger browser compositing layers and can affect performance:

Optimization Suggestions ​

  1. Avoid large area usage: Limit the scope of blend modes
css
/* ❌ Poor performance: entire page blending */
body {
  mix-blend-mode: multiply;
}

/* ✅ Better: limit to specific elements */
.specific-element {
  mix-blend-mode: multiply;
}
  1. Use transform to improve performance:
css
.blended {
  mix-blend-mode: multiply;
  transform: translateZ(0); /* Create separate compositing layer */
}
  1. Avoid changing blend modes in animations:
css
/* ❌ Poor performance */
@keyframes bad {
  from {
    mix-blend-mode: normal;
  }
  to {
    mix-blend-mode: multiply;
  }
}

/* ✅ Better: use opacity to control blend intensity */
.better {
  position: relative;
}

.better::before {
  content: "";
  position: absolute;
  inset: 0;
  background: /* some color or pattern */;
  mix-blend-mode: multiply; /* Fixed blend mode */
  opacity: 0;
  transition: opacity 0.3s;
}

.better:hover::before {
  opacity: 1;
}

Browser Compatibility ​

Blend modes have good support in modern browsers:

  • mix-blend-mode: Chrome 41+, Firefox 32+, Safari 8+, Edge 79+
  • background-blend-mode: Chrome 35+, Firefox 30+, Safari 8+, Edge 79+

For unsupported browsers, provide fallbacks:

css
.element {
  /* Fallback: use semi-transparent overlay */
  background-color: rgba(52, 152, 219, 0.5);
}

@supports (mix-blend-mode: multiply) {
  .element {
    background-color: #3498db;
    mix-blend-mode: multiply;
  }
}

Common Issues ​

Issue 1: Blend Modes Not Working ​

Ensure elements have actual content to blend with:

css
/* ❌ Problem: no lower content, blending ineffective */
.isolated {
  isolation: isolate; /* Create new stacking context */
  mix-blend-mode: multiply;
}

/* ✅ Solution: ensure there's background or lower elements */
.container {
  background: url("image.jpg");
}

.overlay {
  mix-blend-mode: multiply;
}

Issue 2: Blend Range Exceeds Expectations ​

Use isolation: isolate to limit blend range:

css
.container {
  isolation: isolate; /* Create isolated stacking context */
}

.container .blend-element {
  mix-blend-mode: multiply;
  /* Only blends with content inside .container, doesn't affect outside */
}

Issue 3: Text Readability Decreases ​

Some blend modes may reduce text readability, use with caution:

css
.readable-blend {
  position: relative;
}

.readable-blend::before {
  /* Use pseudo-element for blending, keep text clear */
  content: "";
  position: absolute;
  inset: 0;
  background: /* decorative background */;
  mix-blend-mode: overlay;
  z-index: -1;
}

Summary ​

CSS Blend Modes bring image editing software-level visual control to web design:

Core Concepts:

  • mix-blend-mode controls element blending with lower content
  • background-blend-mode controls blending between background layers
  • 16 blend modes each have characteristics and use cases

Common Scenarios:

  • Creative text effects
  • Image colorization and filters
  • Brand element adaptation
  • Dynamic visual effects
  • Texture overlay

Best Practices:

  • Limit usage scope to ensure performance
  • Use isolation to control blend range
  • Provide fallbacks for unsupported browsers
  • Pay attention to text readability

Blend modes open new dimensions of visual creativity. Use them appropriately, and you can create stunning effects that make web design more vivid and professional.