rgb()
Defines the color value by providing three comma separated values. The first value represents the red value, the second represents the green value, and the third represents the blue value.
Syntax
<property>: rbg(red, green, blue);
where red
, green
, blue
can be one of the following:
- Number values: ranging between
0
and255
- Percentage values: ranging between
0%
and100%
Example 1
Set the font color of the h1
element to be white:
h1 {color: rgb(255, 255, 255);}
Example 2
Set the font color of the h1
element to be black:
h1 {color: rgb(0, 0, 0);}
Example 3
Set the font color of the h1
element to be a lavender color:
h1 {color: rgb(230, 230, 250);}