Skip to content

Guide

3-digit vs 6-digit hex colors: when shorthand works

The 3-digit shorthand isn't a rounded approximation — it's a strict digit-doubling rule that only some colors happen to satisfy.

By Published

#FFF and #FFFFFFboth render as identical, pure white in every browser — the 3-digit form isn’t a rougher approximation of the 6-digit one, it’s an exact shorthand defined by the CSS spec. But that equivalence only holds for a specific subset of colors: the shorthand works by duplicating each digit, so it can only represent colors where every channel happens to be a repeated pair, like FF, 66, or 00. Most colors don’t satisfy that constraint and simply can’t be written in 3 digits at all.

The expansion rule

Per the W3C CSS Color Module, a 3-digit hex color #RGB expands to 6 digits by doubling each character: #RGB becomes #RRGGBB. So #F63 expands to #FF6633 — the F becomes FF, the 6 becomes 66, the 3 becomes 33. This is purely mechanical digit repetition, not interpolation or rounding — there’s no color between #FF6633and any neighboring 6-digit value that the shorthand is “averaging” toward.

Which colors qualify for shorthand

6-digit hexCan shorten to 3 digits?
#FFFFFFYes → #FFF
#FF6633Yes → #F63
#00AA88Yes → #0A8
#FF6B35No — 6B and 35 aren't doubled digits
#1A2B3CNo — none of the three pairs are doubled

In practice, only a small fraction of the 16.7 million colors a 6-digit hex code can represent are eligible for shorthand — exactly 16 × 16 × 16 = 4,096 out of 16,777,216, since each channel is restricted to one of 16 doubled-digit values instead of 256 possible byte values. Most real-world brand colors, photo-sampled colors, and design-tool exports land outside that set and stay at 6 digits.

Why it matters when writing CSS

The shorthand is purely a convenience for hand-writing a small number of round, common colors (pure white, pure black, primary red/green/blue) — it saves three characters and nothing else. There’s no performance or rendering difference between the two forms, so most generated or copy-pasted colors (from a color pickeror exported from design software) simply stay at 6 digits, since they rarely land on a doubled-digit value by coincidence. If you’re unsure whether a hex value is valid or want the equivalent RGB numbers regardless of digit count, a hex to RGB converter handles both forms identically.

Frequently asked questions

How does the 3-digit hex shorthand expand to 6 digits?
Each of the three digits is duplicated: #RGB expands to #RRGGBB. So #F63 becomes #FF6633 — the F becomes FF, the 6 becomes 66, the 3 becomes 33. It's a digit-doubling rule, not a rounding or approximation.
Can every 6-digit hex color be written as 3 digits?
No — only colors where each channel is a repeated-digit pair (like FF, 66, 33, AA, 00). A color like #FF6B35 can't be shortened because 6B and 35 aren't doubled digits; only #FF6633-style colors, where both digits of each pair match, qualify.
Do browsers treat #FFF and #FFFFFF differently?
No, they render identically — the CSS spec defines the 3-digit form as pure shorthand notation for the exact same color, not a lower-precision or different color space. #FFF is white, exactly the same white as #FFFFFF.
Is there a 4-digit hex shorthand too?
Yes — #RGBA expands to #RRGGBBAA the same way, adding a shorthand alpha channel. #F63C expands to #FF6633CC, following the same digit-doubling rule as the 3-digit form.

Sources & references

Authoritative references cited by this piece. Verified by Buğra Sözeri on the dates shown and re-checked at every deploy.

Related

More guides on this topic

Published September 25, 2026