rgba()
The rgba()
functional notation expresses a color according to its red, green, and blue components. An optional alpha component represents the color's transparency.
Note: CSS Colors Level 4 allows for space-separated in addition to comma-separated values.
Syntax
rgba(255, 255, 255) /* white */
rgba(255, 255, 255, .5) /* white with 50% opacity */
rgba(255 255 255 / 0.5); /* CSS Colors 4 space-separated values */
Values
- Functional notation:
rgba(R, G, B[, A])
-
R
(red),G
(green), andB
(blue) can be either<number>
s or<percentage>
s, where the number255
corresponds to100%
.A
(alpha) can be a<number>
between0
and1
, or a<percentage>
, where the number1
corresponds to100%
(full opacity). - Functional notation:
rgba(R G B[ / A])
-
CSS Colors Level 4 adds support for space-separated values in the functional notation.
Browser compatibility
BCD tables only load in the browser
Space-separated values
BCD tables only load in the browser