0

Encoded

RGB Color (Hex)
Notation
RGB Color
Color space
Notation

About RGB Color

RGB color is a color model that represents colors by combining three light components: red, green, and blue. It is widely used for colors handled on screens, such as displays, web pages, and image data.

In RGB, the intensity of each component is specified with a numeric value. It is commonly represented as an integer from 0 to 255, or as a percentage from 0% to 100%. When all components are 0, the color is black; when all components are at their maximum, the color is white.

ColorRGB notationHex notation
Redrgb(255 0 0)#ff0000
Greenrgb(0 128 0)#008000
Bluergb(0 0 255)#0000ff
Whitergb(255 255 255)#ffffff
Blackrgb(0 0 0)#000000

RGB colors can be written in function notation or hexadecimal notation. For example, red can be represented as rgb(255 0 0), rgb(100% 0% 0%), #ff0000, or #f00.

To include transparency, add an alpha value. For example, semi-transparent red can be represented as rgb(255 0 0 / 50%) or #ff000080.

DenCode RGB color conversion supports the following notation options.

RGB color (hex)
Notation optionFormatExample
#RRGGBB(AA)#RRGGBB
#RRGGBBAA
#ff0000
#ff000080
0xAARRGGBB0xAARRGGBB0xffff0000
0x80ff0000
RGB color
Notation optionFormatExample
Numberrgb(R G B)
rgb(R G B / A)
rgb(255 0 0)
rgb(255 0 0 / 0.5)
Percentagergb(R% G% B%)
rgb(R% G% B% / A)
rgb(100% 0% 0%)
rgb(100% 0% 0% / 0.5)

0xAARRGGBB is not standard CSS hexadecimal color notation, but it is an ARGB format sometimes used in programs and application settings. The leading AA represents alpha, followed by RR, GG, and BB for red, green, and blue.

sRGB and Other RGB Color Spaces

RGB is a color model that represents colors with three components: red, green, and blue. However, even with the same RGB values, the actual color differs depending on which color space is used for interpretation. Common web rgb() and #RRGGBB values are normally handled as colors in the sRGB color space.

CSS Color Module Level 4 also defines RGB color spaces whose gamuts differ from sRGB, such as Display P3 and ProPhoto RGB. DenCode also supports conversion for these color spaces.

Color spaceFormatExampleCharacteristics
sRGBrgb(...)
color(srgb ...)
rgb(255 0 0)
color(srgb 1 0 0)
The common RGB color space for the web and CSS. Hex color codes and ordinary rgb() values are basically handled as sRGB. color(srgb ...) is a CSS Color Module Level 4 format.
Linear sRGBcolor(srgb-linear ...)color(srgb-linear 1 0 0)A color space that uses the same gamut as sRGB but represents values with linearized components. It is used for color calculation and compositing.
Display P3color(display-p3 ...)color(display-p3 1 0 0)A wider-gamut color space than sRGB, used on wide-gamut displays and some mobile devices.
Adobe RGB (1998)color(a98-rgb ...)color(a98-rgb 1 0 0)A wider-gamut color space than sRGB, sometimes used in photo editing and print-oriented workflows.
ProPhoto RGBcolor(prophoto-rgb ...)color(prophoto-rgb 1 0 0)An RGB color space with an even wider gamut than Adobe RGB, used as a working color space in photo editing.
Rec. 2020color(rec2020 ...)color(rec2020 1 0 0)An RGB color space with a very wide gamut, used in UHDTV and HDR video standards.

Colors specified in wide-gamut RGB color spaces may not be represented accurately on sRGB screens or with ordinary hexadecimal color codes. When DenCode converts to #RRGGBB or numeric rgb(R G B), components outside the sRGB representable range are handled so that they fit within the range from 0 to 255. On the other hand, selecting a color space such as color(display-p3 ...) or color(a98-rgb ...) allows the color to be displayed as component values in the selected color space.