
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
CSS Transparency Using RGBA
Use the RGBA() values for CSS transparency. Set the alpha channel parameter to specify the opacity for color −
.transparent { background-color: rgba(0, 0, 255, 0.582); }
RGBA color value includes the rgba(red, green, blue, alpha). Here, the alpha is to be set for transparency i.e. −
0.0: fully transparent
1.0: fully opaque
Transparency With RGBA
The following is the code for implementing CSS transparency using RGBA. Here, we have set the alpha parameter to a value 0.582 for transparency −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { width: 200px; height: 200px; background-color: rgb(0, 0, 255); color: white; display: inline-block; } .transparent { background-color: rgba(0, 0, 255, 0.582); } </style> </head> <body> <h1>Transparency using RGBA example</h1> <div class="transparent"> This is a demo text. </div> <div> This is another demo text. </div> </body> </html>
Full Transparency With RGBA
The following is the code for implementing CSS transparency using RGBA. Here, we have set the alpha parameter to a value 0.0 for full transparency −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { width: 200px; height: 200px; background-color: rgb(0, 0, 255); color: white; display: inline-block; } .transparent { background-color: rgba(0, 0, 255, 0.0); } </style> </head> <body> <h1>Transparency using RGBA example</h1> <div class="transparent"> This is a demo text. </div> <div> This is another demo text. </div> </body> </html>
Fully Opaque With RGBA
The following is the code for implementing CSS transparency using RGBA. Here, we have set the alpha parameter to a value 1.0 for fully opaque −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { width: 200px; height: 200px; background-color: rgb(0, 0, 255); color: white; display: inline-block; } .transparent { background-color: rgba(0, 0, 255, 1.0); } </style> </head> <body> <h1>Transparency using RGBA example</h1> <div class="transparent"> This is a demo text. </div> <div> This is another demo text. </div> </body> </html>
Advertisements