What Are HEX Color Codes?
A HEX color code is a six-digit hexadecimal number used in HTML, CSS, and design software to represent colors. The format is #RRGGBB, where RR is the red component, GG is the green component, and BB is the blue component. Each pair ranges from 00 (0 in decimal) to FF (255 in decimal), giving a total of 16,777,216 possible colors.
How to Read HEX Color Codes
Reading hex codes is easier than it looks. The hash symbol (#) indicates that what follows is a hex color value. The six characters after the hash are divided into three pairs. The first pair (RR) controls how much red is in the color, the second pair (GG) controls green, and the third pair (BB) controls blue. For example, #FF0000 means maximum red (FF), no green (00), and no blue (00) — which produces pure red.
Each hexadecimal digit can be 0-9 or A-F, where A=10, B=11, C=12, D=13, E=14, and F=15. To read a value like "FF" (the maximum for any channel), multiply the first digit (F=15) by 16 and add the second digit (F=15): (15 × 16) + 15 = 255. That's why RGB values range from 0 to 255.
3-Digit vs 6-Digit HEX Codes
CSS also supports 3-digit shorthand hex codes like #F3A, which expands to #FF33AA. Each digit is doubled to create the full six-digit code. This is only possible when each pair of digits is a repeat (like FF, 33, AA). The 3-digit format saves space but offers fewer color options since you cannot represent all 16.7 million colors with only 12 bits (4 bits per channel).
Important Colors and Their HEX Codes
| Swatch | Color Name | HEX Code | RGB | Tools |
|---|---|---|---|---|
| Black | #000000 | 0, 0, 0 | ||
| White | #ffffff | 255, 255, 255 | ||
| Red | #ff0000 | 255, 0, 0 | ||
| Green | #00ff00 | 0, 255, 0 | ||
| Blue | #0000ff | 0, 0, 255 | ||
| Yellow | #ffff00 | 255, 255, 0 | ||
| Cyan | #00ffff | 0, 255, 255 | ||
| Magenta | #ff00ff | 255, 0, 255 | ||
| Orange | #ffa500 | 255, 165, 0 | ||
| Purple | #800080 | 128, 0, 128 | ||
| Pink | #ffc0cb | 255, 192, 203 | ||
| Brown | #a52a2a | 165, 42, 42 | ||
| Gray | #808080 | 128, 128, 128 | ||
| Navy | #000080 | 0, 0, 128 | ||
| Teal | #008080 | 0, 128, 128 | ||
| Maroon | #800000 | 128, 0, 0 | ||
| Lime | #00ff00 | 0, 255, 0 | ||
| Gold | #ffd700 | 255, 215, 0 | ||
| Silver | #c0c0c0 | 192, 192, 192 | ||
| Coral | #ff7f50 | 255, 127, 80 | ||
| Indigo | #4b0082 | 75, 0, 130 | ||
| Crimson | #dc143c | 220, 20, 60 | ||
| Turquoise | #40e0d0 | 64, 224, 208 | ||
| Salmon | #fa8072 | 250, 128, 114 |
Understanding the HEX Notation
The hex color system is based on the additive RGB color model, which is the same model used by computer screens. Each pixel on your display is made up of three sub-pixels: one red, one green, and one blue. By varying the intensity of each sub-pixel, your monitor can display millions of different colors.
In hex notation, each color channel is represented by two hexadecimal digits, which gives 256 possible values per channel (16 × 16 = 256). This matches the 8-bit per channel standard used in most image formats and displays. The total color space is 256 × 256 × 256 = 16,777,216 colors, which is more than the human eye can distinguish.
For example, the hex code #FF5733 breaks down as follows: Red = FF (255, maximum intensity), Green = 57 (87), Blue = 33 (51). The result is a vibrant orange-red color. By adjusting these three values, you can create any color visible on a standard RGB display.
Common HEX Color Patterns
Here are some patterns to help you read hex codes at a glance:
- Grayscale: When R=G=B, the color is gray.
#000000is black,#808080is medium gray,#FFFFFFis white. - Primary colors:
#FF0000(red),#00FF00(green),#0000FF(blue) — only one channel is at maximum. - Pastel colors: High values across all channels with one slightly higher, e.g.,
#FFB6C1(light pink). - Dark colors: Low values across channels, e.g.,
#2F4F4F(dark slate gray).
Try Our Color Converters
Frequently Asked Questions
What is a hex code?
A hex code (short for hexadecimal code) is a six-digit representation of a color using the base-16 numbering system. It is written as a hash symbol (#) followed by six hexadecimal digits (0-9 and A-F), structured as #RRGGBB where RR is red, GG is green, and BB is blue.
How to read hex colors?
Hex colors are read in three pairs: the first two digits represent red, the middle two represent green, and the last two represent blue. Each pair ranges from 00 (zero intensity) to FF (maximum intensity). For example, #FF0000 is pure red because red is maxed out (FF) while green and blue are at zero (00).
What is the difference between 3-digit and 6-digit hex?
A 3-digit hex code like #F3A is a shorthand notation that expands to #FF33AA. Each digit is doubled to get the full 6-digit code. The 3-digit format is more compact but limited — it only works when each color channel has a repeated digit (like FF, 33, AA), giving only 4,096 possible colors instead of 16,777,216.
Are hex codes case-sensitive?
No, hex codes are case-insensitive. #FF5733, #ff5733, and #Ff5733 all represent the same color. However, the most common convention is to use uppercase letters (A-F) for readability, though lowercase is also widely used in modern CSS.
How many hex colors are there?
There are 16,777,216 possible hex colors (256 × 256 × 256), which is the full sRGB color space available on most modern displays. This gives you every possible combination of red, green, and blue values from #000000 (black) to #FFFFFF (white).