You can specify the background color of an element using a valid color name (e.g., “red”), a HEX value (e.g., “#ff0000”), an RGB (red, green, blue) value (e.g., “rgb(255, 0, 0)”) or an RGBA (red, green, blue, alpha) color value. Here are some examples:
<div class="demo-container">
<p>background-color: #FFFFFF;</p>
<p>background-color: rgb(255, 255, 255);</p>
<p>background-color: rgba(255, 255, 255, 1.0);</p>
<p>background-color: rgba(255, 255, 255, 0.64);</p>
</div>
.demo-container {
padding: 1.4rem;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
padding: 2rem;
}
.demo-container p {
padding: 1rem;
margin-bottom: 1rem;
border-radius: 4px;
}
.demo-container p:nth-child(1) {
/* HEX value (white ) */
background-color: #FFFFFF;s
}
.demo-container p:nth-child(2) {
/* white RGB background color */
background-color: rgb(255, 255, 255);
}
.demo-container p:nth-child(3) {
/* white RGBA background color without transperancy */
background-color: rgba(255, 255, 255, 1.0);
}
.demo-container p:nth-child(4) {
/* white RGBA background color with 64% transperancy */
background-color: rgba(255, 255, 255, 0.64);
}