CSS | rgb() Function
The rgb() function is an inbuilt function in CSS which is used to define the colors using the Red Green Blue (RGB) model.
Syntax:
rgb( red, green, blue )
Parameters: This function accepts three parameters as mentioned above and described below:
- red: This parameter is used to define the intensity of red color. It is an integer value lies between 0 to 255, or as a percentage value between 0% to 100%.
- green: This parameter is used to define the intensity of green color. It is an integer value lies between 0 to 255, or as a percentage value between 0% to 100%.
- blue: This parameter is used to define the intensity of blue color. It is an integer value lies between 0 to 255, or as a percentage value between 0% to 100%.
Below programs illustrates the rgb() function in CSS:
Program:
<!DOCTYPE html> <html> <head> <title>rgb function</title> <style> .gfg1 { background-color:rgb(1, 153, 0); text-align:center; } .gfg2 { background-color:rgb(0, 255, 0); text-align:center } .gfg3 { background-color:rgb(133, 150, 150); text-align:center } .gfg { font-size:40px; font-weight:bold; color:green; text-align:center; } h1 { text-align:center; } </style> </head> <body> <div class = "gfg">GeeksforGeeks</div> <h1>The rgb() Function</h1> <p class = "gfg1">Green</p> <p class = "gfg2">Light green</p> <p class = "gfg3">Light black</p> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by rgb() function are listed below:
- Chrome 1.0 and above
- Internet Explorer 4.0 and above
- Firefox 1.0 and above
- Safari 1.0 and above
- Opera 3.5 and above
Recommended Posts:
- PHP | min( ) Function
- PHP | cos( ) Function
- PHP | Ds\Set add() Function
- PHP | ord() Function
- PHP | next() Function
- PHP | pi( ) Function
- PHP | each() Function
- PHP | pow( ) Function
- PHP | dir() Function
- PHP | Ds\Set first() Function
- PHP | Ds\Set last() Function
- PHP | exp() Function
- PHP | Ds\Set contains() Function
- PHP | max( ) Function
- PHP | sin( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



