Sub topic 2
Hex codes: writing RGB in base 16
Assume you know that RGB stores red, green, and blue channel values, and that each channel can range from 0 to 255. This chapter connects that screen notation to the ink-based CMYK model used in print.
Hex codes: writing RGB in base 16
A hex colour code writes three 8-bit RGB values using base 16. Each channel uses two hexadecimal digits:
00means 0.FFmeans 255.80means 128.
The six digits follow this order: red, green, blue. Therefore, #ff8800 means red 255, green 136, and blue 0. Hexadecimal uses 0–9 and A–F, where A represents 10 and F represents 15.
.button {
background-color: #ff8800;
border-color: rgb(255 136 0);
color: #fff;
}The shorthand #fff expands to #ffffff. Each repeated digit is doubled, so it represents full red, green, and blue. Do not confuse a hex code with a colour space. Hex describes channel values; sRGB defines how those values relate to displayed colour.
Subtractive mixing: how ink absorbs light
Screens emit light. Ink does the opposite: it absorbs some wavelengths and reflects the rest. This is subtractive mixing because adding ink removes light from the reflected result.
Cyan absorbs much of the red light, magenta absorbs green, and yellow absorbs blue. In theory, combining cyan, magenta, and yellow can absorb nearly all visible light and produce black. Real inks are imperfect, so the result is usually a muddy dark brown or grey.
The CMYK model and why black ink exists
CMYK adds a black channel, written as K, to cyan, magenta, and yellow.
| Channel | Main purpose |
|---|---|
| C | Absorbs red |
| M | Absorbs green |
| Y | Absorbs blue |
| K | Supplies dense black and neutral detail |
Black ink improves text sharpness, reduces the amount of coloured ink needed, and produces more reliable dark tones. A design exported for print may therefore use CMYK values instead of RGB values.
Exercise
What RGB values does #3a7fc4 contain?
Show answer
Red is 0x3a (58), green is 0x7f (127), and blue is 0xc4 (196).