English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When using CSS, you can use the CSS rgb() function to provide color values. It allows you to specify RGB color values by directly specifying the red, green, and blue channels.
Using RGB color:
!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style> #p1 {background-color:rgb(255,0,0);} #p2 {background-color:rgb(0,255,0);} #p3 {background-color:rgb(0,0,255);} #p4 {background-color:rgb(192,192,192);} #p5 {background-color:rgb(255,255,0);} #p6 {background-color:rgb(255,0,255);} </style> </head> <body> <p>RGB color:</p> <p id="p1">Red</p> <p id="p2">Green</p> <p id="p3">Blue</p> <p id="p4">Gray</p> <p id="p5">Yellow</p> <p id="p6">Cherry color</p> </body> </html>Test and see ‹/›
The rgb() function uses the superposition of three colors: red (R), green (G), and blue (B) to generate various colors.
RGB stands for Red, Green, Blue (English: Red, Green, Blue).
Red (R)to 255 The integer between the two represents the red component of the color.
Green (G)to 255 The integer between the two represents the green component of the color.
Blue (B)to 255 The integer between the two represents the blue component of the color.
Supported version: CSS2
The numbers in the table represent the first browser version number that supports the function.
Function | |||||
---|---|---|---|---|---|
rgb() | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
rgb(red, green, blue)
Value | Description |
---|---|
red | Define the red value, the range is 0 ~ 255, also can use percentage 0% ~ 100% |
green | Define the green value, the range is 0 ~ 255, also can use percentage 0% ~ 100% |
blue | Define the blue value, the range is 0 ~ 255, also can use percentage 0% ~ 100% |