rgb() CSS Function

Description

The rgb() function can be used to provide a color value when using CSS. It allows you to specify an RGB color value by specifying the red, green, and blue channels directly.

Syntax

rgb() = rgb( <red>, <green>, <blue> )

Values

  • <red>This value can be either a <number> or <percentage> where the number 255 corresponds to 100%
  • <green>This value can be either a <number> or <percentage> where the number 255 corresponds to 100%
  • <blue>This value can be either a <number> or <percentage> where the number 255 corresponds to 100%

Example

<div class="rgb">This is an example of the rgb() function.</div>
.rgb {
background-color: rgb(134, 56, 78);
color: white;
border: 2px solid red;
margin: 20px;
padding: 20px;
text-align: center;
}

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
312113.51
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
≤37184Yes1Yes