COLOR FUNDAMENTALS
Hex colors and modern CSS formats
Hex is a compact notation for sRGB channel values. It is ideal for simple opaque web colors, but modern CSS also supports alpha channels, perceptual color spaces, and wide-gamut values.
Six-digit hex: #RRGGBB
A standard opaque hex color contains six hexadecimal digits after a number sign. The first pair controls red, the second green, and the third blue. Each pair ranges from 00 to FF, equivalent to decimal values from 0 through 255.
| Color | Red | Green | Blue |
|---|---|---|---|
#FF0000 | 255 | 0 | 0 |
#00FF00 | 0 | 255 | 0 |
#0000FF | 0 | 0 | 255 |
#8493AA | 132 | 147 | 170 |
Hexadecimal is base 16, using digits 0–9 and letters A–F. Two hex digits can represent 256 values, which matches an eight-bit RGB channel.
Three-digit shorthand: #RGB
CSS allows three-digit shorthand when each channel can be represented by repeating one digit. Each digit is duplicated:
#09F → #0099FF #ABC → #AABBCC #FFF → #FFFFFF
Shorthand is not “less precise” for the specific expanded value; it simply represents a much smaller set of possible colors. #8493AA cannot be reduced because its channel pairs do not repeat one digit.
Four and eight-digit hex add alpha
CSS Color 4 supports alpha transparency as a final component:
#RGBAexpands each digit, including alpha.#RRGGBBAAuses two hex digits for alpha.
#0008 /* expands to #00000088 */ #00000080 /* black at about 50% alpha */ #8493AAFF /* fully opaque */
00 alpha is fully transparent and FF is fully opaque. The visual result of a transparent color depends on the backdrop beneath it, so it does not have one standalone appearance or contrast ratio.
Hex describes sRGB values
In CSS, hex notation directly specifies an sRGB color. RGB, HSL, HWB, named colors, and hex values all resolve to sRGB. The same numeric color may still appear different across displays because of brightness, calibration, ambient light, panel behavior, and color management.
Hex is a notation, not a perceptually uniform design model. Equal numeric changes do not necessarily look equally large to the eye.
Other CSS color formats
| Format | Best used for | Example |
|---|---|---|
| HEX | Compact opaque sRGB values and familiar design handoff | #8493AA |
| RGB | Direct sRGB channels and alpha composition | rgb(132 147 170 / 80%) |
| HSL | Human-readable hue, saturation, and lightness adjustments inside sRGB | hsl(216 20% 59%) |
| HWB | Hue with whiteness and blackness controls | hwb(216 52% 33%) |
| Lab / LCH | Device-independent and perceptual color work | lch(62% 15 260) |
| OKLab / OKLCH | Perceptually even adjustments, palettes, gradients, and controlled chroma | oklch(65% .06 255) |
color() | Explicit spaces such as Display P3, Rec. 2020, or ProPhoto RGB | color(display-p3 .5 .58 .68) |
Modern CSS functional syntax uses spaces between components and an optional slash before alpha. Legacy comma-separated RGB and HSL syntax remains supported for compatibility.
Why designers use OKLCH
OKLCH separates perceptual lightness, chroma, and hue. It is useful when you want steps that appear more evenly spaced than simple HSL changes.
- Lightness is easier to reason about for tonal scales.
- Chroma controls colorfulness without conflating it with lightness.
- Hue is an angle, making harmony relationships convenient.
OKLCH can describe colors outside sRGB. Browsers must map out-of-gamut results to what the output device can display, so always test important colors on representative devices and provide fallbacks when your support requirements demand them.
How HexCheck handles hex values
- The Color Utility accepts opaque three- or six-digit hex values and normalizes them to six digits.
- Permanent color routes use six-digit values such as
/8493aa. - Letter case does not change the color; your account preference controls copied hex casing.
- Your account preference can include or omit the leading
#when copying supported values. - Transparent four- and eight-digit values are not used for permanent Color Utility pages because their appearance depends on a backdrop.
- Pro developer tools expose additional representations such as RGB, HSL, OKLCH, CSS, and design-token formats.
Common mistakes
- Do not place the alpha bytes first. CSS eight-digit notation is
#RRGGBBAA, not Android-style#AARRGGBB. - Do not assume a lighter HSL number guarantees better perceived contrast.
- Do not compare transparent colors without compositing them over the real backdrop.
- Do not use a wide-gamut value without checking browser and display behavior.
- Do not rely on a color conversion alone to prove accessibility; test the actual foreground and background.