sRGB triples written as rgb() or #RRGGBB
On the web, an opaque color is three bytes in the sRGB space: red, green, and blue, each an integer from 0 through 255. CSS accepts that triple as rgb(r, g, b) or as six hexadecimal digits #RRGGBB—the same numbers, two notations.
Hex digits are base 16, which is why a channel such as 128 becomes 80. Confirm a single channel with the radix converter, sample a pixel with the color picker, and tidy a stylesheet with the CSS formatter.
Bytes, hex pairs, and the sRGB default
Why each RGB channel is a byte from 0 to 255
- One channel is an 8-bit unsigned integer: 256 levels, from no light (0) to full primary (255).
- The three channels are independent—changing green does not rescale red or blue.
- rgb(255, 128, 0) is full red, mid green, and zero blue in sRGB, not a print ink mix.
- Browsers treat plain rgb() and #RRGGBB as sRGB unless a wider space such as display-p3 is named.
How two hex digits encode one channel
- Base 16 uses 0–9 and A–F; two digits cover 0 through 255 exactly (16×16).
- The high digit is sixteens, the low digit is ones: 0x80 = 8×16+0 = 128.
- #RRGGBB concatenates the three pairs in red, green, blue order.
- Letter case does not change the value: #ff8000 and #FF8000 are the same triple.
Three-digit #RGB shorthand versus six digits
- CSS expands #RGB by repeating each digit: #F80 becomes #FF8800, not #F80000.
- That expansion is not the same as padding with zeros.
- Shorthand cannot express every 24-bit color—only values where each channel’s two digits match.
- Design tokens usually store the six-digit form so every byte is explicit.
What stays outside a plain RGB hex triple
- Alpha lives in rgba() or an extra #AARRGGBB / #RRGGBBAA pair—opacity is not a fourth sRGB primary.
- HSL and OKLCH describe hue and lightness; converting them to RGB is a different formula.
- CMYK and Display P3 are other spaces—the same hex digits can look different on a wide-gamut screen if the profile changes.
- A hex literal in source code is still sRGB bytes until a color-space function says otherwise.
Where the two notations meet
Brand specs and CSS variables
Style guides often print #RRGGBB while stylesheets mix rgb() in shadows and gradients—both name the same sRGB bytes.
Computed styles in DevTools
Browsers frequently show computed colors as rgb(). The hex form is the same triple packed into three bytes.
Frequently asked questions
How do I convert RGB to hex online?
How do I convert hex color to RGB?
How do I convert #RRGGBB to rgb() for CSS?
Why do designers use hex while CSS allows rgb()?
What is sRGB and why does it matter?
Is #FF0000 the same as rgb(255, 0, 0)?
Does this tool support #RGB shorthand?
Can I convert a single channel from decimal to hex?
RGB ↔ hex reference
rgb(255, 255, 255)White — #FFFFFFrgb(0, 0, 0)Black — #000000rgb(255, 0, 0)Red — #FF0000rgb(255, 128, 0)Orange — #FF8000rgb(59, 130, 246)Blue (Tailwind blue-500) — #3B82F6rgb(16, 185, 129)Emerald — #10B981#6366F1Indigo — rgb(99, 102, 241)