How to give the opacity to div without affecting for text

In this post i am going to tell you how to give the opacity to the div background not for the text. If you give opacity:0.1 something like this it takes whole div include text in the particular div, so you can't able to view text clearly. so you should give the opacity to the background only means you should use the code like this background-color: rgba(255,0,0,0.1);

This is one of the simple css trick really helps to you. The below image shows the result of the above code. 255,0,0 is the color code of red  and opacity is 0.1. see the image it applies only the background not for the div text.

The code for background opacity:

<title>Background color with opacity not text</title>

.div1 {
font-size: 50px;
text-align: center;
margin: 10px auto;
background-color: rgba(255,0,0,0.1);

<div class='div1'></div>
<p style="margin-top:150px;">&nbsp;</p>
<p><a href=""><h1></h1></a></p>

Post a Comment