- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Declaring a Fallback Color in CSS
The Fallback color is used to specify the color for a situation when the browser doesn’t support RGBA colors. Some browsers that don’t support fallback colors are Opera. Specify a solid color before a RGBA color so the solid color can still work if the browser doesn’t support the RGBA colors.
Set the Fallback Color
The following is the code for declaring a fallback color in CSS −
background-color: purple; /*fallback color*/
Example
Let us see an example −
<!DOCTYPE html> <html> <head> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } div { padding:20px; font-size: 24px; background-color: purple; /*fallback color*/ background-color: rgba(128, 0, 128, 0.527); color:white; } </style> </head> <body> <h1>Fallback color example</h1> <div>Some random text inside this div</div> </body> </html>
Set the Fallback Color With rgb()
Example
The Modern browsers will first apply rgb() and then move to the next line and overwrite it with rgba(). Let us see an example −
<!DOCTYPE html> <html> <head> <style> p { padding:20px; font-size: 24px; background-color: rgb(255, 99, 71); /*fallback color*/ background-color: rgb(255, 99, 71, 0.6) } </style> </head> <body> <h1>Fallback color example</h1> <p>Some random text</p> </body> </html>
Advertisements