What is the difference between opacity and rgba in CSS?
opacity makes the whole element transparent, including text and children. rgba() makes only the colour transparent.
.a { opacity: 0.5; } /* text also fades */
.b { background: rgba(0, 115, 170, 0.5); } /* text stays solid */
Output in the browser
opacity 0.5
rgba background
See CSS Opacity.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Colors |
| CSS Background |
| CSS Gradients |
| CSS Images |
| Exercises & Assignments |
|---|
| Write CSS to change the text colour and background of a paragraph |
| Interview Questions & Answers |
|---|
| How to add a background image in CSS? |
| What is the difference between opacity and rgba in CSS? |