A comprehensive guide to digital color formats. Learn how HEX, RGB, HSL, and CMYK represent colors, and discover WCAG contrast rules for accessible web design.
Calculate your numbers instantly in your browser. Fast, free, no signup.
Color representation is one of the most critical bridges between graphic designers, front-end developers, and browser rendering engines. While human vision perceives a continuous electromagnetic spectrum, digital displays and printing presses require discrete numerical coordinates to recreate colors accurately.
Understanding the difference between HEX, RGB, HSL, and CMYK enables you to select the right color model for web styling, user experience design, and digital-to-print production.
Digital displays (OLED, LCD, LED) generate color by emitting light from microscopic red, green, and blue subpixels. This is known as an additive color model:
0, the screen emits no light: Black (rgb(0, 0, 0)).255, the light waves combine to produce: Pure White (rgb(255, 255, 255)).A HEX color code is simply RGB expressed in base-16 (hexadecimal) notation preceded by a hash symbol (#):
#RRGGBB
Hexadecimal uses digits 0–9 followed by letters A–F (where A = 10 and F = 15). Two hex digits represent one 8-bit byte ($16 \times 16 = 256$ possibilities):
00 in hex equals 0 in decimal.FF in hex equals 255 in decimal.Example: #3B82F6 decomposes to:
3B hex = (3 × 16) + 11 = 5982 hex = (8 × 16) + 2 = 130F6 hex = (15 × 16) + 6 = 246rgb(59, 130, 246)While RGB and HEX are optimal for hardware, they are unintuitive for humans. If a client asks you to "make that button slightly darker or a bit less vibrant", tweaking RGB values requires complex guesswork.
HSL maps color onto a cylindrical coordinate system that mirrors human perception:
0° = Red120° = Green240° = Blue0% is grayscale, 100% is fully vivid).0% is total black, 50% is normal color, 100% is total white).Example: To create hover or active states in CSS, simply adjust the lightness: hsl(217, 91%, 60%) → hsl(217, 91%, 50%).
Unlike screens that emit light, physical printed paper reflects ambient light. Inks absorb (subtract) certain wavelengths while reflecting others. This is why print designs use the subtractive CMYK model.
Because CMYK has a smaller color gamut than RGB, vivid screen colors (like bright neon greens or electric blues) often appear muted when printed on physical paper.
The Web Content Accessibility Guidelines (WCAG 2.1) require sufficient contrast between text and background colors to ensure legibility for users with visual impairments:
Need to convert hex codes to RGB, explore HSL adjustments, check CMYK values, or verify WCAG accessibility contrast scores? Use our free Color Converter & Contrast Checker.