liveBook · Manning

Hexadecimal color notation

As explained in Web Design Playground

A hexadecimal notation for specifying a color by encoded red, green, and blue channel values.

Hexadecimal color notation is a compact way to tell CSS which red, green, and blue amounts make up a color. Think of it as a six-character paint recipe: two characters for red, two for green, and two for blue. A code starts with #, so its pattern is #rrggbb. section 17.11

Read a hex color from left to right:

  • # marks the value as a hexadecimal color. section 17.11
  • The first pair, rr, controls red; the second, gg, controls green; and the third, bb, controls blue. section 17.11
  • Each pair can range from 00 to ff. More than one channel can contribute, so colors can be bright mixes as well as pure red, green, or blue. section 17.11
Name Red Color
Red #ff000
Green #00ff00
Blue #0000ff
Yellow #ffff00
Magenta #ff00ff
Cyan #00ffff
Black #000000
Gray #808080
White #ffffff

Use these familiar color recipes as landmarks: #ff0000 is red, #00ff00 is green, #0000ff is blue, and #ffffff is white. section 17.11

Color a heading purple

Put a hex triplet after the CSS color property: h1 { color: #800080; } Here, 80 supplies red, 00 supplies green, and 80 supplies blue, producing purple. The same color could be expressed with rgb(), but the hex form keeps the three channel values together in one short code. section 17.11 section 17.12

You do not need to guess a color from its code. A Color Chooser can display a selected color together with its RGB hex triplet, rgb() value, hsl() value, and keyword when one applies. Enter a hex triplet directly, or pick and adjust a color visually. section 17.14

Hex values also work as starting points for a color scheme. Enter one into a Color Scheme Calculator, choose complementary, analogous, triadic, split complementary, or monochrome, and inspect the resulting colors. For example, #77613c can anchor a warm brown monochrome palette. section 17.16 section 20.4

Try it: choose a favorite color in a Color Chooser, copy its hex triplet, and use it with color or background-color. Then feed that same value into a scheme calculator to find companion colors. section 17.14 section 17.29

How Web Design Playground covers it

How deep it goes
Defines #rrggbb channel positions and ranges, then works through a purple CSS declaration without detailing hexadecimal conversion generally.
Examples
Uses common-color codes, a purple h1 rule, and brown or gold values as inputs to generated color schemes.
What it assumes
Introduces hexadecimal color notation by comparing it with rgb() and identifying red, green, and blue components.
What you can do after
Apply it via CSS color and background-color properties or enter a hex triplet into color-selection tools.
How it connects
Connects hexadecimal colors with rgb(), hsl(), color keywords, transparency functions, CSS color properties, and color schemes.

Also explained in

Compare how 4 books explain hexadecimal color notation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.