Understanding Color Spaces: RGB, HSL, HEX, and CMYK Explained

February 11, 2026 · 9 min read · Design

Color is everywhere in digital design, but the way we represent and manipulate colors varies dramatically depending on the color space we use. Whether you're a web developer writing CSS, a designer creating palettes, or a print professional preparing files, understanding color spaces is essential. This guide breaks down the most important color models — RGB, HSL, HEX, CMYK, and HSB — and explains when and why to use each.

What Is a Color Space?

A color space is a mathematical model that describes the range of colors that can be represented. Think of it as a coordinate system for color — just as you use latitude and longitude to locate a point on Earth, you use color space coordinates (like R, G, and B values) to locate a specific color.

Different color spaces exist because different media (screens, printers, cameras) produce color differently. Screens emit light (additive color), while printers absorb light with ink (subtractive color). Each medium needs a model that maps to how it physically creates color.

RGB: The Foundation of Screen Color

RGB stands for Red, Green, Blue — the three primary colors of light. Every pixel on your screen combines these three channels at varying intensities (0-255 each) to produce over 16.7 million possible colors.

/* CSS RGB notation */
color: rgb(99, 102, 241);    /* Indigo */
color: rgb(16, 185, 129);    /* Emerald green */
color: rgba(99, 102, 241, 0.5); /* 50% transparent */

/* Modern CSS syntax */
color: rgb(99 102 241 / 50%);  /* Newer syntax */

How it works: At (0, 0, 0), all channels are off — you get black. At (255, 255, 255), all channels are at maximum — you get white. Equal values of R, G, and B produce grays. Mixing produces secondary colors: Red + Green = Yellow, Red + Blue = Magenta, Green + Blue = Cyan.

When to use RGB: When working with screens, LED lighting, video, or any light-emitting medium. RGB is the native language of displays. Use it in CSS when you need precise channel control or alpha transparency.

HEX: RGB in Compact Notation

HEX color codes are simply RGB values written in hexadecimal (base-16). The format #RRGGBB packs three bytes into a 6-character string. Each pair represents one channel: 00 = 0, FF = 255.

#6366F1  →  R:99  G:102  B:241
#FF0000  →  Pure red
#00FF00  →  Pure green
#000000  →  Black
#FFFFFF  →  White

/* Shorthand: #RGB expands to #RRGGBB */
#F00  →  #FF0000
#ABC  →  #AABBCC

/* 8-digit HEX includes alpha */
#6366F180  →  ~50% transparent indigo

When to use HEX: HEX is the most common format in web development because it's compact and universally supported. Use it for static color definitions in CSS, design tokens, and brand guidelines. However, it's hard to mentally adjust — changing "brightness" by tweaking hex values requires understanding the math.

HSL: Human-Friendly Color

HSL stands for Hue, Saturation, Lightness. It maps color to how humans actually perceive it, making it far more intuitive than RGB for design work.

/* CSS HSL notation */
color: hsl(239, 84%, 67%);      /* Indigo */
color: hsl(160, 84%, 39%);      /* Emerald */
color: hsla(239, 84%, 67%, 0.5); /* 50% transparent */

/* Creating variations is intuitive */
--primary: hsl(239, 84%, 67%);
--primary-light: hsl(239, 84%, 80%);  /* Just change L */
--primary-dark: hsl(239, 84%, 40%);
--primary-muted: hsl(239, 30%, 67%);  /* Lower S */

Why HSL is better for designers: Need a lighter shade? Increase L. Need a muted version? Decrease S. Want the complementary color? Add 180° to H. These operations are nearly impossible to do intuitively with RGB or HEX. Use our Color Converter to see the HSL values for any color.

HSB/HSV: Designer's Color Model

HSB (Hue, Saturation, Brightness) — also called HSV (Value) — is similar to HSL but defines brightness differently. In HSB, 100% brightness means the purest form of the color, while in HSL, 100% lightness always gives white.

HSB is the default model in design tools like Figma, Adobe Photoshop, and Sketch. If you're picking colors in a design tool, you're likely using HSB. When converting to CSS, you'll need to translate to HSL, RGB, or HEX.

CMYK: The Print Color Model

CMYK stands for Cyan, Magenta, Yellow, and Key (black). It's a subtractive color model used in printing. While screens add light to create color, printers absorb (subtract) light using ink.

Important: CMYK has a smaller gamut (range of possible colors) than RGB. Bright, vibrant screen colors often look duller when printed. This is why designers must preview their work in CMYK before sending to print. Colors like electric blue (#0000FF) or neon green simply cannot be reproduced in print.

Modern CSS Color Spaces

CSS is evolving beyond RGB and HSL. Modern browsers now support wider color gamuts and perceptually uniform color spaces:

/* OKLCH - perceptually uniform, wide gamut */
color: oklch(70% 0.15 240);

/* Lab color space */
color: lab(70% -20 50);

/* Display P3 (wider than sRGB) */
color: color(display-p3 0.4 0.4 0.95);

/* Relative color syntax (future CSS) */
--lighter: oklch(from var(--color) calc(l + 20%) c h);

OKLCH is particularly promising because it's perceptually uniform — equal steps in lightness look equally different to human eyes, unlike HSL where hue shifts can appear uneven.

Color Conversion: How It Works

Converting between color spaces involves mathematical formulas. Here are the key relationships:

Rather than doing these calculations manually, use our Color Converter tool which handles all conversions instantly with live preview.

Practical Tips for Choosing Color Spaces

  1. Web development: Use HSL for defining color systems (easy to create variations), HEX for static values, and RGB when you need alpha transparency
  2. Design systems: Define colors in HSL, store as HEX tokens, and use OKLCH for perceptually balanced palettes
  3. Print design: Always work in CMYK for print projects. Convert from RGB early to avoid color surprises
  4. Accessibility: Use contrast ratios (based on relative luminance from RGB) to ensure text readability. WCAG requires 4.5:1 for normal text and 3:1 for large text
  5. Dark mode: HSL makes dark mode trivial — reduce lightness values while keeping hue and saturation consistent
🎨 Convert Colors Instantly

Try our Color Converter to switch between HEX, RGB, and HSL — now with palette generation and WCAG contrast checking built in.

Conclusion

Understanding color spaces isn't just academic — it directly impacts your design quality and workflow efficiency. RGB and HEX dominate web development, HSL empowers intuitive design, CMYK is essential for print, and modern spaces like OKLCH represent the future. Master these models, and you'll make better color decisions across every medium you work in.