Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS rgb() Function

CSS rgb() Function

CSS Functions CSS Functions

Example

Using 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 »


Definition and usage

The rgb() function generates a wide variety of colors by combining red (R), green (G), and blue (B).

RGB stands for Red, Green, Blue.

Supported version: CSS2


Browser support

The numbers in the table indicate the first browser version that 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 red value, ranging from 0 to 255; a percentage from 0% to 100% can also be used.
green Defines the green value, ranging from 0 to 255; a percentage from 0% to 100% can also be used.
blue Defines the blue value, ranging from 0 to 255; a percentage from 0% to 100% can also be used.

CSS Functions CSS Functions