RGB color space or RGB color system constructs all the colors from combinations of the Red, Green, and Blue colors. Each color channel uses 8 bits with integer values from 0 to 255, making 256 × 256 × 256 = 16,777,216 possible colors.
RGB ≡ Red, Green, Blue
Each pixel on an LED monitor displays colors by combining red, green, and blue LEDs.
When a channel is set to 0, that LED is off; when set to 255, the LED is fully on.
Values in between produce varying light intensity.
RGB color codes are stored in 24 bits (bits 0..23):
RED[7:0] = bits 16-23 GREEN[7:0] = bits 8-15 BLUE[7:0] = bits 0-7
Calculation of the decimal integer from R, G, and B values:
Decimal = R × 256² + G × 256 + B
= R × 65536 + G × 256 + B
Calculation of the hex code from R, G, and B values:
Hex = "#" + two-digit-hex(R) + two-digit-hex(G) + two-digit-hex(B)
This table shows common RGB colors with their name, R, G, B values, Hex code, Decimal value, and a short description.
| Name | R | G | B | Hex | Decimal | Description |
|---|---|---|---|---|---|---|
| Red | 255 | 0 | 0 | #FF0000 | 16711680 | Pure Red |
| Green | 0 | 255 | 0 | #00FF00 | 65280 | Pure Green |
| Blue | 0 | 0 | 255 | #0000FF | 255 | Pure Blue |
| Black | 0 | 0 | 0 | #000000 | 0 | No color, Black |
| White | 255 | 255 | 255 | #FFFFFF | 16777215 | White, all colors combined |
| Yellow | 255 | 255 | 0 | #FFFF00 | 16776960 | Red + Green |
| Cyan | 0 | 255 | 255 | #00FFFF | 65535 | Green + Blue |
| Magenta | 255 | 0 | 255 | #FF00FF | 16711935 | Red + Blue |
HSV (Hue, Saturation, Value) is an alternative way to represent colors.
Conversion from RGB to HSV helps in understanding and manipulating colors in a more intuitive way.
RGB stands for Red, Green, Blue—the three primary colors of light. In digital systems, colors are represented as combinations of these three values, each ranging from 0 to 255. When all three are set to 0, you get black. When all are set to 255, you get white.
An RGB color is written as: rgb(R, G, B) where R, G, and B are integers between 0 and 255.
rgb(255, 0, 0)rgb(0, 255, 0)rgb(0, 0, 255)You can mix these values to create millions of colors.
RGB colors can also be written in hexadecimal format as #RRGGBB, where each pair of digits represents the red, green, and blue values respectively. Example:
#FF0000 → Red#00FF00 → Green#0000FF → Blue#FFFF00 → Yellow| Color | RGB | Hex |
|---|---|---|
| Black | rgb(0, 0, 0) | #000000 |
| White | rgb(255, 255, 255) | #FFFFFF |
| Red | rgb(255, 0, 0) | #FF0000 |
| Green | rgb(0, 255, 0) | #00FF00 |
| Blue | rgb(0, 0, 255) | #0000FF |
| Yellow | rgb(255, 255, 0) | #FFFF00 |
| Cyan | rgb(0, 255, 255) | #00FFFF |
| Magenta | rgb(255, 0, 255) | #FF00FF |
Web designers use RGB and Hex codes to style elements with specific colors in CSS:
body {
background-color: rgb(240, 240, 240);
color: #333333;
}
Each color channel (Red, Green, Blue) influences the final color’s brightness and hue. Example:
Designers and developers use digital color pickers to:
Choosing the right color contrast ensures readability, especially for users with visual impairments. Tools like WCAG Contrast Checkers help validate:
Many tools help convert between RGB, Hex, and even HSL (Hue, Saturation, Lightness). Example conversion:
rgb(255, 0, 0) → #FF0000 → hsl(0, 100%, 50%)
Using multiple RGB values, you can create gradients in CSS:
background: linear-gradient(to right, rgb(255, 0, 0), rgb(0, 0, 255));
This will create a smooth red-to-blue gradient across the background.
RGB color codes are an essential part of digital design, development, and visualization. Whether you're building a website, designing an app, or manipulating images, understanding how to work with RGB and its representations helps you craft clear, beautiful, and user-friendly visuals.