Skip to main content
Hexadecimal
FF

Hexadecimal System Guide

Hexadecimal System

The hexadecimal system uses 16 symbols: 0-9 and A-F (A=10, B=11, C=12, D=13, E=14, F=15). It's a shorthand for binary - each 4 bits is one hex digit. Example: 11111111₂ = FF₁₆ = 255₁₀. Used in programming and colors.

Why Hex Matters

Binary 255 is 11111111 (8 digits). Hex FF (2 characters) - easier for humans to read and enter. Memory addresses, RGB colors, Unicode code points use hex. Color definitions in CSS: #FF0000 (red), #00FF00 (green), #0000FF (blue).

Practical Applications

In CSS colors: #3498db blue, #2ecc342 green. In UUID v5: 550e8400-ea29-41d3-af15-6528adf68cc2. ROM/EEPROM dumps as hex. MAC addresses: aa:bb:cc:dd:ee:ff. In debuggers memory addresses as 0x0040A7C0.

#888 is not #808080, and CSS shorthand reaches 0.02% of colours

Hexadecimal is compact binary: one digit is exactly four bits, so two digits are one byte. That is why a colour is written as three pairs. The three-digit CSS shorthand expands by doubling each digit rather than scaling it, which means most colours have no shorthand at all — including mid grey.

How it works

  • Converts between hexadecimal, decimal and binary, with each hex digit mapping to four bits.
  • Handles colour values, where two hex digits give the 256 levels of one channel.
  • Makes the digit-to-bit correspondence explicit, since that is what all the conventions rest on.
1 hex digit  = 4 bits = 16 values (0–F)
2 hex digits = 8 bits = 256 values (00–FF)

#RRGGBB = 3 channels × 8 bits = 24 bits = 16,777,216 colours
#RGB shorthand expands by doubling: #F0A → #FF00AA

Worked example

Comparing the full six-digit form against the three-digit shorthand.

  1. #RRGGBB is 24 bits: 16,777,216 colours
  2. #RGB is 12 bits: 4,096 colours
  3. shorthand covers 0.0244% of the space
  4. #888 expands to #888888 = 136 per channel
  5. but mid grey is #808080 = 128 per channel

#888 and #808080 differ by 8 levels in every channel, and no three-digit code produces #808080. Shorthand is not an abbreviation of all colours — it is a small subset that happens to be writable in half the characters.

Reading the result

  • Expansion doubles the digit, it does not scale the range. #A becomes #AA, not a value proportionally placed — which is why the shorthand palette lands on 0x00, 0x11, 0x22 and so on in steps of 17, missing everything between.
  • Hex survives because the mapping to binary is exact and mechanical. A byte is always two characters, conversion needs no arithmetic, and there is no rounding to introduce error — the same reasons it is used for hashes, MAC addresses and memory dumps.
  • Case is not significant in colour values or in most parsers: #FF00AA and #ff00aa are identical. It matters in hashes only where a specification says so, and comparing hex strings without normalising case is a common source of false mismatches.
  • The 0x prefix marks hex in most programming languages, # marks it in CSS, and some contexts use neither. A bare string of digits and letters is ambiguous — 10 is ten in decimal and sixteen in hex, and nothing about the characters tells you which.

Common questions

Why are colours written in hex rather than decimal?
Because each channel is one byte, and one byte is exactly two hex digits. In decimal the same colour is rgb(255, 0, 170) — three variable-length numbers with separators, against six fixed characters that split cleanly into channels.
Can I always shorten a hex colour?
Only when each pair is a repeated digit. #FF00AA shortens to #F0A because every pair repeats; #808080 cannot be shortened at all, because 80 is not a doubled digit. Roughly one colour in 4,096 has a shorthand.