CSS rgb() Function
Example
Define different RGB colors:
#p1 {background-color:rgb(255,0,0);} /* red */
#p2 {background-color:rgb(0,255,0);} /* green */
#p3 {background-color:rgb(0,0,255);} /* blue */
Try it Yourself »
Definition and Usage
The CSS rgb() function define colors using the Red-green-blue (RGB) model.
An RGB color value is specified with: rgb(red, green, blue). Each parameter defines the intensity of that color and can be an integer between 0 and 255 or a percentage value (from 0% to 100%).
For example, the rgb(0,0,255) value is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.
Version: | CSS2 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
Function | |||||
---|---|---|---|---|---|
rgb() | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
CSS Syntax
rgb(red, green, blue)
Value | Description |
---|---|
red | Defines the intensity of red as an integer between 0 and 255, or as a percentage value between 0% and 100% |
green | Defines the intensity of green as an integer between 0 and 255, or as a percentage value between 0% and 100% |
blue | Defines the intensity of blue as an integer between 0 and 255, or as a percentage value between 0% and 100% |