CSS rgb() function | rgb html
❮CSSFunctionsReference[1]ExampleDefinedifferentRGBcolors:#p1{background-color:rgb(255,0,0);}/*red*/#p2{background-color:rgb(0,255,0);}/*green*/#p3{background-color:rgb(0,0,255);}/*blue*/TryitYourself»[2]DefinitionandUsageThergb()functiondefinecolorsusingtheRed-green-blue(RGB)model.AnRGBcolorvalueisspecifiedwith:rgb(red,green,blue).Eachparameterdefinestheintensityofthatcolorandcanbeanintegerbetween0and255orapercentagevalue(from0%to100%).Forexample,thergb(0,0,255)valueisrenderedasblue,becauset...
❮ CSS Functions Reference[1]
ExampleDefine 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 » [2] Definition and UsageThe 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.
Browser SupportThe 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 Value Description red Defines the int...