Categories
CSS

How to give text or an image a transparent background using CSS?

Spread the love

Sometimes, we want to give text or an image a transparent background using CSS

In this article, we’ll look at how to give text or an image a transparent background using CSS.

How to give text or an image a transparent background using CSS?

To give text or an image a transparent background using CSS, we set the background-color property.

For instance, we write

<p style="background-color: rgba(255, 0, 0, 0.5)">
  <span>Hello, World!</span>
</p>

to set the background-color to a rgba value.

The last value is the opacity.

Conclusion

To give text or an image a transparent background using CSS, we set the background-color property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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