Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS background-blend-mode Property

Posted in CSS Tutorial
Updated on Sep 04, 2024
By Mari Selvan
👁️ 16 - Views
⏳ 4 mins
💬 1 Comment
CSS background-blend-mode Property

Photo Credit to CodeToFun

🙋 Introduction

The background-blend-mode property in CSS allows web developers to control how multiple background images are blended together.

This property defines the blending mode for each layer, making it possible to create complex visual effects by combining colors and images in different ways.

💡 Syntax

The background-blend-mode property is applied to an element that has multiple background layers. The syntax is as follows:

Syntax
Copied
Copy To Clipboard
element {
  background-blend-mode: blend-mode;
}

Here, blend-mode can be one of several predefined values that determine how the background layers interact.

🎛️ Default Value

The default value of the background-blend-mode property is normal, which means that the background layers are simply stacked without any blending.

🏠 Property Values

ValueDescription
normalThe default behavior, where background layers are displayed as they are.
multiplyMultiplies the colors of the background layers, resulting in a darker effect.
screenThe inverse of multiply, resulting in a lighter effect.
overlayCombines multiply and screen to preserve the highlights and shadows of the background layers.
darkenDisplays the darker colors from the background layers.
lightenDisplays the lighter colors from the background layers.
color-dodgeBrightens the background layers, making the colors more intense.
color-burnDarkens the background layers, increasing the contrast.
hard-lightSimulates a strong light source, combining multiply and screen.
soft-lightSimilar to hard-light, but with softer edges and transitions.
differenceSubtracts the colors of the background layers from each other.
exclusionSimilar to difference, but with lower contrast.
hueApplies the hue (color tone) of the blend layer to the base layer.
saturationApplies the saturation of the blend layer to the base layer.
colorApplies the color of the blend layer to the base layer while preserving brightness.
luminosityApplies the brightness of the blend layer to the base layer while preserving color.

📄 Example

In this example, we'll blend two background images using the multiply blend mode.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS background-blend-mode Example</title>
  <style>
    .blended-background {
      width: 100%;
      height: 300px;
      background-image: url('image1.jpg'), url('image2.png');
      background-blend-mode: multiply;
      background-size: cover;
    }
  </style>
</head>
<body>
  <h1>Background Blend Mode Example</h1>
  <div class="blended-background"></div>
</body>
</html>

🖥️ Browser Compatibility

The background-blend-mode property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is important to test your website in different browsers to ensure that the blend modes render as expected.

🎉 Conclusion

The background-blend-mode property offers a powerful way to create visually striking effects by blending multiple background images together. Whether you're looking to enhance a design with subtle texture or create a dynamic, layered background, this property provides the flexibility to achieve your desired effect. Experiment with different blend modes to see how they can transform your web designs.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy