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
CSS 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 of the p element to rgba(255, 0, 0, 0.5)
.
Then the background color will apply to everything inside.
Conclusion
To give text or an image a transparent background using CSS, we set the background-color
CSS property.