ColourPilot
Complete Handbook

Complete HEX Color Guide

Learn what HEX color codes are, how they work, how to read them, convert them to RGB and use them in CSS, HTML and modern web design.

1. What is a HEX Color?

HEX color codes are one of the most common ways to represent colors on the web. They are used in CSS, HTML, design software and development tools to define precise colors using hexadecimal values.

A HEX color is an alphanumeric code composed of six characters preceded by a hash symbol (#). It is a direct digital instruction telling computer screens and monitors how much Red, Green, and Blue light to emit from their pixels to render a specific color.


2. Why is it called HEX?

"HEX" stands for hexadecimal, which is a base-16 positional numeral system. Unlike our standard base-10 decimal system that uses ten symbols (0-9), hexadecimal uses sixteen symbols to represent values.

These symbols include standard digits from 0 to 9, followed by the letters A, B, C, D, E, and F to represent numbers ten through fifteen:

A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

3. HEX Color Format

The structure of a standard HEX color code follows a precise format representing three color channels:

#RRGGBB
  • RR (Red Channel): The first two digits define the intensity of Red light (ranging from 00 for none to FF for maximum brightness).
  • GG (Green Channel): The middle two digits define the intensity of Green light (ranging from 00 to FF).
  • BB (Blue Channel): The final two digits define the intensity of Blue light (ranging from 00 to FF).

4. 3-digit vs 6-digit HEX

In stylesheet syntax, you will often find shorthand three-digit codes instead of full six-digit values. When a three-digit code is parsed by a browser, the browser replicates each individual digit to fill a six-digit format.

Shorthand 3-Digit

#FFF

#000

Expanded 6-Digit Equivalent

#FFFFFF (White)

#000000 (Black)


5. 8-digit HEX & Transparency

Modern CSS standards support 8-digit HEX codes, which incorporate an extra alpha transparency channel:

#RRGGBBAA

The final two characters (AA) represent alpha opacity levels. For example, #FF000080 represents red light at 50% opacity (80 in hex represents 128 in decimal, which is roughly 50% of 255).


6. How Browsers Read HEX

When a browser reads a HEX code in a CSS file, it parses the string, converts the hexadecimal pairs into standard 8-bit binary integers (values from 0 to 255), and passes these digital instructions to the computer graphics card. The display device then drives the voltage of the pixel subcomponents to project light accordingly.


7. How HEX Converts to RGB

To convert a HEX code to decimal RGB values, split the code into three channels and multiply the positional coordinates.

Conversion Example: #3498DB (Ocean Blue)

Red (34)

(3 × 16) + 4 = 52

Green (98)

(9 × 16) + 8 = 152

Blue (DB)

(13 × 16) + 11 = 219

Result: rgb(52, 152, 219)


8. Common HEX Examples

ColorHEX CodeRGB Equivalent
Black#000000rgb(0, 0, 0)
White#FFFFFFrgb(255, 255, 255)
Red#FF0000rgb(255, 0, 0)
Blue#0000FFrgb(0, 0, 255)
Green#00FF00rgb(0, 255, 0)

9. Where HEX is Used

HEX is supported universally across the digital creation ecosystem:

  • Frontend Code: CSS declarations and HTML configuration tags.
  • UI Design tools: Figma, Sketch, Adobe XD.
  • Creative platforms: Photoshop, Canva, Illustrator.
  • Style packages: Tailwind CSS themes, Bootstrap variables.

10. Advantages & Limitations

Advantages

  • Concise notation string.
  • Extremely easy to copy and paste.
  • Universally supported by browsers and graphic apps.

Limitations

  • Hard to read or predict values without calculations.
  • Not mathematically intuitive for color adjustments.

11. HEX vs RGB vs HSL vs CMYK

Understanding how HEX compares to other digital color formats is essential for picking the right tool for the job.

HEX vs RGB

Both represent the sRGB additive light coordinates. HEX maps values to hexadecimal strings while RGB states them in base-10 decimals.

FeatureHEX FormatRGB Format
Syntax#3498DBrgb(52, 152, 219)
CompactnessHigh (7 chars)Low (17 chars)

HEX vs HSL

HEX is machine-oriented, detailing channel light amounts. HSL is human-oriented, describing the Hue angle, Saturation percentage, and Lightness levels.

FeatureHEX FormatHSL Format
Syntax#3498DBhsl(204, 70%, 53%)
Intuitive EditingLowHigh (easy to lighten or saturate)

HEX vs CMYK

HEX represents additive digital display light. CMYK represents subtractive print ink channels (Cyan, Magenta, Yellow, Key Black).

FeatureHEX FormatCMYK Format
MediumScreens & DisplaysPaper & Printing Press
Gamut SizeLarge (sRGB)Small (subject to print ink limitations)

12. Common Mistakes & Best Practices

Common Pitfalls

  • Forgetting the hash symbol (#): CSS engines will fail to interpret the value as a color without the hashtag prefix.
  • Invalid characters: Using characters outside the hexadecimal range (G through Z are invalid).
  • Incorrect length: Using 4 or 5 characters instead of standard 3, 6, or 8 formats.

Best Practices

  • Maintain code consistency by using either uppercase or lowercase characters exclusively throughout your codebase.
  • Write CSS variables or design tokens to capture HEX values globally.
  • Prefer 6-digit values for maximum developer clarity.

13. Frequently Asked Questions

What is a HEX color?

A HEX color code is a six-digit, base-16 number that represents colors in the sRGB color model. It consists of three two-digit hex values defining the intensities of Red, Green, and Blue light.

Why are HEX colors six digits?

HEX colors use six digits because they represent three color channels (Red, Green, and Blue), with each channel allocated two hexadecimal digits (8 bits of data, or values from 0 to 255 in decimal).

Why does HEX start with #?

The pound sign (#), also called a hash or octothorpe, is a standard prefix in CSS, HTML, and design software to signal that the following character sequence is a hexadecimal color value rather than a keyword string.

Can HEX include transparency?

Yes, using the 8-digit HEX format (#RRGGBBAA). The final two digits represent the alpha opacity channel (ranging from 00 for fully transparent to FF for fully opaque).

How do I convert HEX to RGB?

To convert, split the six-digit code into three pairs (RR, GG, BB). Convert each pair from base-16 to base-10. For example, #3498DB splits to Red 34 (52 in decimal), Green 98 (152 in decimal), and Blue DB (219 in decimal).

Is HEX better than RGB?

Neither is intrinsically better, but HEX is more compact and easier to copy/paste in code variables. RGB is useful when calculating color ranges or working with scripting languages.

Why do web developers use HEX?

Web developers prefer HEX because it is short, standard, copy-friendly, and natively supported by all browsers and graphic tools like Figma and Photoshop.

Are HEX colors supported by all browsers?

Yes, HEX color notation is a core W3C standard supported by 100% of graphical web browsers.

Can I use HEX in CSS?

Yes! HEX values can be applied to any CSS color property, including background, color, border-color, and box-shadow.

Is #FFF the same as #FFFFFF?

Yes, #FFF is a shorthand 3-digit version of #FFFFFF. The browser expands each digit by replicating it (F becomes FF), resulting in identical color rendering.

What is 8-digit HEX?

An 8-digit HEX code (#RRGGBBAA) adds a two-digit alpha channel (AA) to the standard Red, Green, and Blue channels to declare transparency levels.

Does HEX affect website performance?

No, color formats (HEX, RGB, HSL) are parsed instantly by browser layout engines with no impact on page render speeds or performance.