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

CSS rgba() Function

CSS rgba() Function

CSS Functions CSS Functions

Example

Using RGBA colors with transparency:

#p1

{

background-color:

rgba

(

255

,

0

,

0

,

0.3

)

;

}

/*

Red

*/

#p2

{

background-color:

rgba

(

0

,

255

,

0

,

0.3

)

;

}

/*

Green

*/

#p3

{

background-color:

rgba

(

0

,

0

,

255

,

0.3

)

;

}

/*

Blue

*/

Try it »


Definition and usage

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

RGBA stands for Red, Green, Blue, Alpha.

Supported version: CSS3


Browser support

The numbers in the table indicate the first browser version that supports the function.

function
rgba() 1.0 4.0 1.0 1.0 3.5

CSS Syntax



rgba(red, green, blue, alpha)

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.
alpha - Alpha Defines alpha from 0 (fully transparent) to 1 (fully opaque)

CSS Functions CSS Functions