Blog

CSS Background Blend Modes: A Practical Example

Color effect with CSS blend-mode applied to a photo

You can blend a photo with a background color using CSS, without editing the original image. The article image shows you a photo where the effect was still created the traditional way in Photoshop. But for the web there is a better approach: you can achieve the same or very similar effects with CSS alone – without Photoshop or any other software.

How does background-blend-mode work?

(1.) Choose the photo you want to embed in your website.

(2.) Use HTML markup to embed the image as a background image on your page. You can do this with a div element, as shown in the example below.

<div class="blendmode_image"></div>

The important thing is to assign a class to the div element. In our case we call the class blendmode_image.

(3.) Give the div a size, set the photo as its background image, and choose a background color. The background-blend-mode property controls how the two blend.

.blendmode_image {
  max-width: 1440px;
  height: 960px;
  background-image: url('../path/to/your/image.jpg');
  background-size: cover;
  background-position-x: center;
  background-color: #2139ec;
  background-blend-mode: difference;
}

And that’s really all there is to it. Besides difference, the background-blend-mode property supports the following additional effects:

  • color
  • color-burn
  • color-dodge
  • darken
  • difference
  • exclusion
  • hard-light
  • hue
  • lighten
  • luminosity
  • multiply
  • overlay
  • saturation
  • screen
  • soft-light

(4.) Try a different background color or blend mode to change the effect. The original photo stays intact, and you can adjust the result entirely in CSS.