Color Tools
Hex Color Codes Explained
A hex color code is a six-character shorthand for an RGB color. Every color you see on a website — every background, every button, every text — is defined by one. Here is exactly how they work.
The structure of a hex code
A hex color code has three parts: a # symbol, followed by six hexadecimal digits. Those six digits are always three pairs, and each pair controls one color channel.
Why hexadecimal?
Each color channel goes from 0 to 255 — that is 256 possible values. In decimal, 255 takes three characters. In hexadecimal (base 16), 255 is just FF — two characters. Using base 16 lets each channel be represented in exactly two digits, keeping the full code compact at six characters.
The digits 0–9 work the same as in decimal. For the values 10–15, hex uses the letters A–F: A=10, B=11, C=12, D=13, E=14, F=15. So FF means (15×16)+15 = 255.
Common hex values you should know
| Color | Hex code | RGB | Notes |
|---|---|---|---|
| #000000 | rgb(0, 0, 0) | All channels off | |
| #ffffff | rgb(255, 255, 255) | All channels max | |
| #ff0000 | rgb(255, 0, 0) | Pure red | |
| #00ff00 | rgb(0, 255, 0) | Pure green | |
| #0000ff | rgb(0, 0, 255) | Pure blue | |
| #808080 | rgb(128, 128, 128) | Mid grey | |
| #ffff00 | rgb(255, 255, 0) | Yellow (R+G, no B) | |
| #ff00ff | rgb(255, 0, 255) | Magenta (R+B, no G) |
3-digit shorthand
When both digits in each pair are identical, you can shorten the code to three digits. #fff expands to #ffffff. #000 expands to #000000. #f0f expands to #ff00ff. This only works for colors where each channel's two hex digits match — so it covers only 4,096 of the full 16.7 million colors.
8-digit hex codes and transparency
Modern CSS supports an 8-digit hex code by adding a fourth pair for the alpha channel (opacity). #1c60f6ff is fully opaque. #1c60f680 is 50% transparent. #1c60f600 is invisible. This is supported in all modern browsers but may not work in older email clients or legacy contexts — rgba() is safer when broad compatibility matters.
Frequently Asked Questions
What are hex color codes used for?
Hex color codes are used to specify colors in web design and digital interfaces. They appear in CSS stylesheets (color: #1c60f6), HTML attributes, design tools like Figma and Photoshop, brand style guides, and anywhere a precise digital color needs to be communicated. They are the standard format for color on the web because they are compact, exact, and universally supported.
How many colors can hex codes represent?
A 6-digit hex code can represent exactly 16,777,216 colors — the same as the full 24-bit RGB color space. This comes from 256 possible values per channel (0–255) across three channels: 256 × 256 × 256 = 16,777,216. A 3-digit hex code shorthand can only represent 4,096 of those colors.
What is the hex code for black and white?
#000000 is black — all three color channels (red, green, blue) are set to zero, meaning no light at all. #ffffff is white — all three channels are at maximum (255 each), meaning full intensity of every color combined. #808080 is a neutral mid-grey, where all channels sit at exactly half intensity.
What does it mean when a hex code has 8 characters?
An 8-digit hex code adds a fourth pair of digits for the alpha channel, which controls transparency. The last two digits range from 00 (fully transparent) to FF (fully opaque). For example, #1c60f680 is the same blue as #1c60f6 but at 50% opacity. This format is supported in modern CSS but not universally in older contexts.
How do I convert a hex color to RGB?
Split the hex code into three pairs and convert each from hexadecimal to decimal. For #1C60F6: 1C = (1 × 16) + 12 = 28, 60 = (6 × 16) + 0 = 96, F6 = (15 × 16) + 6 = 246. So the RGB value is rgb(28, 96, 246). You can use the HEX to RGB converter at quicktoolshub.org/hex-to-rgb to do this instantly.
Why do some hex codes start with letters like A, B, or F?
Hexadecimal is base 16, which needs 16 digits. The standard digits 0–9 only give ten values, so the letters A–F are used for the remaining six: A=10, B=11, C=12, D=13, E=14, F=15. So a hex pair like FF means (15 × 16) + 15 = 255 — the maximum value. This is why #ffffff (all channels at maximum) represents white.