English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete List of CSS Properties

CSS rgba() function

The CSS rgba() function can be used to provide a color value with alpha transparency in CSS. It allows you to specify an RGB color value and an alpha value to determine the transparency of the color.

CSS Function

Online Example

Use RGBA color and opacity:

!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic Tutorial(oldtoolbag.com)</title>
<style>
#p1 {background-color:rgb(255,0,0,0.3);}
#p2 {background-color:rgb(0,255,0,0.3);}
#p3 {background-color:rgb(0,0,255,0.3);}
#p4 {background-color:rgb(192,192,192,0.3);}
#p5 {background-color:rgb(255,255,0,0.3);}
#p6 {background-color:rgb(255,0,255,0.3);}
</style>
</head>
<body>
<p>RGB color, and use opacity:</p>/p>
<p id="p1">Red</p>
<p id="p2">Green</p>
<p id="p3">Blue</p>
<p id="p4">Gray</p>
<p id="p5">Yellow</p>
<p id="p6">Cherry red</p>
</body>
</html>
Test to see ‹/›

Definition and Usage

The rgba() function uses the superposition of Red (R), Green (G), Blue (B), and Alpha (A) to generate various colors.

RGBA stands for Red, Green, Blue, and Alpha.

  • Red (R)0 to 255 integer between

  • Green (G)0 to 255 integer between

  • Blue (B)0 to 255 integer between

  • Opacity (A)Value 0~1 representing opacity.

Supported Versions: CSS3

Browser Compatibility

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

Function




rgba()1.04.01.01.03.5

CSS Syntax

rgba(red, green, blue, alpha)
ValueDescription
redDefine the red value, ranging from 0 ~ 255, which can also be expressed as a percentage 0% ~ 100%.
greenDefine the green value, ranging from 0 ~ 255, which can also be expressed as a percentage 0% ~ 100%.
blueDefine the blue value, ranging from 0 ~ 255, which can also be expressed as a percentage 0% ~ 100%.
alpha - OpacityDefine opacity 0 (fully transparent) ~ 1(Completely Transparent)

CSS Function