background-blend-mode
Example
.hero {
background: url("photo.jpg") center / cover;
background-blend-mode: multiply;
}.hero {
background: url("photo.jpg") center / cover, #2a4d8f;
background-blend-mode: multiply;
}Adding a color layer gives multiply something to blend with, creating a tinted duotone photo.
Common mistakes
- The blend mode has no effect because the element has only one background layer.
- The background is expected to blend with the page behind it, but it only blends with its own layers.
Key points
- The element has both a
background-colorand abackground-image, or several images, so there is something to blend. - Blending inside one element uses
background-blend-mode; blending with content behind the element usesmix-blend-mode. - Text over a blended image is checked for contrast, since blend modes change the final colors.
Interview questions
What is the difference between background-blend-mode and mix-blend-mode?
background-blend-mode blends the background layers of one element. mix-blend-mode blends the whole element with what is behind it.
Can I set a different blend mode for each background layer?
Yes. Give a comma-separated list of modes in the same order as the background layers.