How to add background opacity with CSS?

Spread the love

Sometimes, we want to add background opacity with CSS.

In this article, we’ll look at how to add background opacity with CSS.

How to add background opacity with CSS?

To add background opacity with CSS, we set the background-color property.

For instance, we write

<div style="background-color: rgba(0, 0, 0, 0.5)">
  <div>Text added.</div>
</div>

to set the background-color of the div to rgba(0, 0, 0, 0.5).

0.5 is the opacity.

Conclusion

To add background opacity with CSS, we set the background-color property.

Leave a Reply

Your email address will not be published. Required fields are marked *