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 | |||||
3 | 12 | 1 | 1 | 3.5 | 1 |
Tablets / Mobile | |||||
![]() |
|||||
≤37 | 18 | 4 | Yes | 1 | Yes |
Last updated by CSSPortal on: 1st December 2019