You've opened Photoshop, or typed a colour into CSS, or picked a highlight in a text editor's theme. You've seen codes that look like this:
#FF5733·#1A1A2E·#00BFFF
Six characters. Two letters, four digits — sometimes more letters, sometimes none. No one ever explains what they mean. You copy them, paste them, and move on.
Here's the question: why are colours written like this? Why not as the three numbers a computer actually uses? Why not as the raw bits a computer actually stores? What is the point of this in-between form that no other counting system in your life uses?
By the end of this lesson you'll decode #FF5733 on sight — and understand why every serious computing context (web development, networking, debugging, assembly code) picks hex over the alternatives.
Hex shows up wherever bytes need to be read by humans. A short list, all drawn from real engineering:
background: #FF5733; in CSS.00:1A:2B:3C:4D:5E on the back of every network card.0x7FFE43A0.0x0000007B, HTTP status 0x190 (= 400).Real-world anchor. The dark navy colour behind the lesson panels on this site is
#1A1A2E. By the end of this lesson you'll know, without looking anything up, that that means 26 red, 26 green, 46 blue — and you'll see it in the binary exactly the way your GPU does.
This lesson builds directly on Lesson 1 — The Binary Number System. You need to be comfortable with:
If those feel shaky, spend five minutes on Lesson 1 before continuing — the hex method here collapses if the binary underneath is not solid.
30-second recap — a 4-bit group (called a nibble) has place values . It can represent any denary value from 0 to 15. Remember this — it is the whole trick of this lesson.
Consider the number 243. There are three ways a computer can describe it:
| Form | Written as | Length |
|---|---|---|
| Denary (base 10) | 243 | 3 characters |
| Binary (base 2) | 11110011 | 8 characters |
| Hex (base 16) | F3 | 2 characters |
All three are the same quantity. They describe the same pattern of bits in memory. They're written differently because different audiences need different things out of them.
Base 16 means you need 16 different symbols. You already have 0–9. The standard hex convention extends with the first six letters of the alphabet:
| Denary | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| Binary (4 bits) | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Worth memorising. The leap from 9 to A is the part that trips people up — remember that after 9 we need six more symbols, so we reuse A through F. F = 15 is the biggest single hex digit, the same way 9 is the biggest single denary digit.
The tool below is the best way to make hex click. Every web colour is three bytes glued together — one for red, one for green, one for blue. Each byte is written as two hex digits. Drag the sliders, or click a preset.
Try these, in order:
80, not a rounder-looking number?Before you touch the sliders again: the colour code #808080 is a medium grey. Predict what R, G, B are in denary — without converting — and then check.
0–9 and A–F, with values 0 through 15 respectively.0x (in code) or # (in CSS) signals that what follows is a hex number. 0xFF is hex FF; FF on its own is ambiguous unless context makes it clear.An -digit hex number has the denary value:
where each is a value from 0 to 15. The place values, from right to left, are — powers of 16.
For a 2-digit hex number, the place values are:
| Hex position | Left digit | Right digit |
|---|---|---|
| Place value | 16 | 1 |
So the hex number A7 equals in denary.
With hex digits, you have patterns, representing values 0 to .
That correspondence — hex digits = bits — is the reason hex exists.
How many denary values can a 3-digit hex number represent?
You could imagine a base-8 (octal) system, or base-4, or base-32. Why did base-16 win?
Two reasons. First: bytes are 8 bits, and 8 splits neatly into two groups of 4 — so two hex digits is exactly one byte. No wasted space, no awkward overflow. Second: four bits fits one "familiar-sized" digit — you can glance at a byte and read off its two halves instantly once you know the 16 symbols. Octal (base 8) would take three digits per byte and feel cramped; base-32 would need too many unfamiliar symbols.
Hex hit the sweet spot for the hardware word sizes that won out in the 1970s, and everything since has followed.
The reason hex is easy to work with is that you never need to convert through denary. Binary and hex translate directly, nibble by nibble.
That's the whole method. Watch it happen live — click any bit below and see the hex update:
Try making these binaries and reading off the hex:
11111111 → what hex? (Should be a familiar value.)00001111 → what hex? Why does the left nibble being all 0s give a leading 0 in hex?10101010 → what hex? Toggle a single bit and see how much the hex changes.You want to convert hex 4B to binary. What do you do?
Convert A7 to denary using positional notation.
The only trick is remembering that A = 10. Everything else is arithmetic.
Convert 200 to hex.
C.A third method exists — go via binary. Convert 200 to 8-bit binary (11001000), split into nibbles (1100 1000), convert each to hex (C and 8). Same answer, C8. Use whichever feels faster; both are correct.
The dark navy panel colour from Section 3 was #1A1A2E. Now you can decode it without tools:
1A = red1A = 26 green2E = blueSo #1A1A2E is rgb(26, 26, 46) — low on everything, slightly more blue than the other two, which is why it reads as a cool dark navy rather than neutral grey.
Six things worth remembering in six months:
Seven questions, mixed types. Expect about 10 minutes.
What denary value does the hexadecimal digit F represent?
Practice exam available
Auto-graded multiple-choice questions. You'll see your percentage, letter grade, and a question-by-question review after submitting.
Start exam →
Work through these problems — solutions in practice-solutions.md.
Convert 3F to denary.
Convert BE to denary.
Convert 100 (denary) to hex.
Convert 254 (denary) to hex.
Convert binary 11100110 to hex.
Convert hex D2 to binary.
The hex colour #1E90FF ('Dodger Blue') has three channel values. Convert each pair to denary and state which channel dominates.
Explain in two sentences why one hex digit corresponds to exactly one nibble (4 bits), and why this makes hex–binary conversion faster than denary–binary conversion.
Extension (A* territory): A MAC address is 48 bits long. How many hex digits does that take? How many possible MAC addresses exist? (Your phone's MAC is one of them.)
Pedagogy and framings adopted here:
Syllabus and exam resources:
Version 1 — published 2026-04-24.