Hexadecimal Color Notation
What you'll learn: How to use hexadecimal codes to define precise colors by mixing red, green, and blue light.
The Core Idea
Hexadecimal color notation is a compact way to specify colors using the RGB (Red-Green-Blue) color model. Just like mixing paint, screens create colors by combining different intensities of red, green, and blue light. Hex codes let you control exactly how much of each color to mix.
A full hex color looks like this: #RRGGBB
- The
#symbol signals "this is a hex color" - The first two characters (
RR) control red intensity - The middle two (
GG) control green intensity - The last two (
BB) control blue intensity
Each pair uses hexadecimal numbers (0-9 and A-F), where 00 means "none of this color" and FF means "maximum intensity."
Examples
color: #FF0000; /* Pure red (max red, zero green, zero blue) */
color: #00FF00; /* Pure green */
color: #0000FF; /* Pure blue */
color: #FFFFFF; /* White (all colors at maximum) */
color: #000000; /* Black (no light at all) */
color: #FF5733; /* Orange-ish (high red, medium green, low blue) */
Shorthand Notation
When both digits in each pair are identical, you can use shorthand #RGB:
color: #F00; /* Same as #FF0000 (red) */
color: #0F0; /* Same as #00FF00 (green) */
color: #FFF; /* Same as #FFFFFF (white) */
color: #C96; /* Same as #CC9966 (tan) */
The browser automatically doubles each digit: #C96 becomes #CC9966.
Key Takeaway: Hexadecimal color notation uses #RRGGBB (or shorthand #RGB) to precisely control red, green, and blue light channels, with values ranging from 00 (none) to FF (maximum).