coderef

RGBBaseline · Widely available

The rgb(), rgba(), and hexadecimal (as in #004488ff) notations pick colors using red, green, blue, and alpha (transparency) channels.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–64Not supported
65+Supportedsince Mar 6, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–51Not supported
52+Supportedsince Mar 7, 2017
Current: 157
Safari
1–12Not supported
12.1+Supportedsince Mar 25, 2019
Current: 27
MobileChrome Android
18–64Not supported
65+Supportedsince Mar 6, 2018
Current: 155
Firefox Android
4–51Not supported
52+Supportedsince Mar 7, 2017
Current: 157
Safari iOS
1–12Not supported
12.2+Supportedsince Mar 25, 2019
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: rgb.

Feature detection

CSS · check before using
@supports (color: color(display-p3 1 0 0)) {
  /* styles that use rgb */
}

/* or in JavaScript */
if (CSS.supports("color", "color(display-p3 1 0 0)")) {
  // use it
}

Sub-features

Support for each part of the feature (7). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
<color>.rgb112111841
<color>.rgb.alpha_parameter65795212.1655212.2
<color>.rgb.float_values66795212.1665212.2
<color>.rgb.mixed_type_parameters1221221131812211318
<color>.rgb.space_separated_parameters65795212.1655212.2
<color>.rgb_hexadecimal_notation112111841
<color>.rgb_hexadecimal_notation.alpha_hexadecimal_notation6279491062499.3