Color Space Basics: HEX/RGB/HSL
RGB (Red Green Blue) is an additive color model that produces colors by superimposing red, green, and blue light at different intensities. Each channel is represented as an integer from 0 to 255. In Canvas, WebGL, and other graphics programming, RGB is also the most natural data type — pixel values are typically stored in R-G-B-A order.
HEX (hexadecimal) is essentially another way to write RGB — each 0-255 channel is written as two hexadecimal digits, prefixed with #. The standard form is #RRGGBB, with a 3-digit shorthand #RGB available when each channel has identical digits. Since CSS Color Module Level 4, #RRGGBBAA (8-digit HEX) and #RGBA are also supported, adding an alpha channel.
HSL (Hue Saturation Lightness) is closer to human perception. Its three dimensions are: hue (0°~360°), saturation (0%~100%), and lightness (0%~100%). HSL's greatest value is "adjusting saturation and lightness while keeping the hue unchanged" — this is critical for generating harmonious color schemes. For example: brand color + lighter hover state + darker active state.