The Three Color Models Every Web Designer Should Know
Every color you see on a screen is defined by a color model, a mathematical way of describing that color as a set of numbers. In web design, three color models dominate: HEX, RGB, and HSL. Each one describes the exact same set of colors, but they approach it from different angles, and that difference matters more than you might think.
HEX codes are the oldest and most widely recognized format on the web. An RGB hex code like #3B82F6 is essentially a compact way of writing three numbers (red, green, blue) in hexadecimal notation. The first two characters represent red (3B = 59), the next two green (82 = 130), and the last two blue (F6 = 246). CSS has supported HEX since the earliest days, which is why you see it everywhere in legacy codebases, design tokens, and brand guidelines.
RGB (Red, Green, Blue) uses the same underlying model but writes it in decimal. The same blue from above becomes rgb(59, 130, 246). This format is more human-readable than HEX, and in CSS it supports an alpha channel for transparency: rgb(59 130 246 / 0.5) gives you a 50% transparent blue. Modern CSS has dropped the need for commas, making it cleaner than ever.
HSL (Hue, Saturation, Lightness) takes a fundamentally different approach. Instead of mixing light channels, you specify a position on the color wheel (hue, 0-360 degrees), how vivid the color is (saturation, 0-100%), and how light or dark it is (lightness, 0-100%). That same blue becomes hsl(217, 91%, 60%). The power of HSL is that it maps to how humans actually think about color: "I want a blue that's a bit lighter" is trivially easy in HSL (just increase lightness) but requires recalculating all three values in RGB.
When to Use Which Format
Choosing between HEX, RGB, and HSL is not just a matter of preference. Each format has practical advantages depending on the context.
Use HEX when you need a compact, widely-compatible color value. Brand guidelines almost always specify HEX codes. They are easy to copy and paste, easy to search for in a codebase, and universally supported. If you are defining a static color that will not change (a brand primary, a specific gray), HEX is the most pragmatic choice. Three-character shorthand like #fff or #333 makes common values even more concise.
Use RGB when you need transparency. Before CSS gained widespread support for the newer color syntaxes, rgba() was the primary way to add alpha transparency. Even today, many design tools export colors as RGB values. If your workflow involves copying values from Figma, Sketch, or Photoshop, you will encounter RGB constantly. It is also the native format for canvas operations and image manipulation in JavaScript.
Use HSL when you are building a design system or need to create color variations programmatically. If your primary brand color is hsl(217, 91%, 60%), generating a hover state is as simple as changing the lightness to 55%. Creating a muted version means reducing saturation. Building an entire palette from a single hue becomes straightforward. CSS custom properties combined with HSL make dynamic theming remarkably elegant. Many modern design systems define their tokens in HSL for exactly this reason.
A practical approach many teams adopt: define your source-of-truth palette in HSL for flexibility, but export HEX for documentation and external communication.
Color Harmony: Building Palettes That Work
A well-designed website rarely uses random colors. Color harmony, the art of combining colors that look good together, follows principles rooted in the physics of light and decades of design theory.
Complementary colors sit opposite each other on the color wheel. Blue and orange, red and green, purple and yellow. These combinations create high contrast and visual energy. They work well for call-to-action buttons against a background or for creating visual emphasis. The danger is overuse: a page split 50/50 between complementary colors feels aggressive. The classic ratio is 60/30/10, using your dominant color for 60% of the design, a secondary for 30%, and the complement as a 10% accent.
Analogous colors are neighbors on the color wheel, like blue, blue-green, and green. These combinations feel calm and cohesive. They are excellent for backgrounds, gradients, and creating a sense of visual flow. Most nature-inspired designs use analogous palettes because they mirror what we see in the natural world.
Triadic colors are evenly spaced around the wheel (every 120 degrees). They offer variety while maintaining balance. Triadic palettes are harder to execute well, but when done right they feel vibrant without being chaotic. Many successful SaaS interfaces use a triadic approach: a blue for trust, an orange for CTAs, and green for success states.
Split-complementary palettes take one base color and pair it with the two colors adjacent to its complement. This gives you the visual contrast of a complementary scheme but with more nuance and less risk of clashing.
ToolForte's Color Palette Generator lets you explore these harmonies interactively. Pick a base color and generate complementary, analogous, triadic, or split-complementary palettes instantly.
Key Takeaway
A well-designed website rarely uses random colors.
Accessibility and Contrast Ratios
Color accessibility is not optional. The Web Content Accessibility Guidelines (WCAG) set specific, measurable standards for color contrast, and many jurisdictions now require compliance by law.
WCAG 2.1 defines two levels of contrast compliance. Level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18px bold or 24px regular). Level AAA raises the bar to 7:1 for normal text and 4.5:1 for large text. Most organizations target AA as their minimum standard.
Contrast ratio is calculated from the relative luminance of two colors. Pure white on pure black gives you 21:1 (the maximum). Pure white on a medium gray might give you 3:1 (insufficient for body text). The math is well-defined but not intuitive, which is why dedicated tools exist. Before finalizing any color combination in your design, check it with a contrast checker.
Common accessibility pitfalls include light gray text on white backgrounds (the number one offender), colored text on colored backgrounds without sufficient contrast, relying solely on color to convey meaning (error states should use icons and text, not just red), and placeholder text that is too light to read.
Beyond contrast ratios, consider color blindness. Roughly 8% of men and 0.5% of women have some form of color vision deficiency. Red-green color blindness is the most common type. Never use red and green as the only differentiator between states. Always provide secondary cues: icons, patterns, labels, or position.
ToolForte's Color Contrast Checker lets you test any two colors against WCAG AA and AAA standards instantly, showing you the exact ratio and whether it passes or fails.
Practical Tips for Choosing Web Colors
Start with your brand's primary color and build outward. A single well-chosen hue can anchor your entire design. Use HSL to generate lighter and darker variants: your primary at 60% lightness becomes a button color, at 95% lightness a subtle background tint, at 30% lightness a hover state. This creates visual cohesion without requiring a designer to hand-pick every shade.
Limit your palette. Most effective websites use 2-3 core colors plus a neutral scale (grays). Every additional color adds cognitive load. If you find yourself reaching for a new color, ask whether an existing one at a different lightness could serve the same purpose.
Test your colors in context, not in isolation. A color that looks perfect in a swatch can feel overwhelming as a full-width header or invisible as a small icon. Always evaluate colors at the scale and context they will actually appear in.
Do not forget dark mode. If your site supports a dark theme, your entire palette needs a second pass. Colors that work well on white backgrounds often need to be desaturated or shifted in lightness for dark backgrounds. HSL makes this adjustment straightforward.
Use the Color Converter on ToolForte to quickly translate between HEX, RGB, and HSL as you work across different tools and contexts. Having the ability to move between formats without manual calculation saves time and eliminates errors, especially when you are pulling colors from a design file into CSS or vice versa.
Key Takeaway
Start with your brand's primary color and build outward.
Related articles
CSS Layout Tools: Grid, Flexbox, Gradients and Shadows
A practical guide to CSS Grid, Flexbox, gradients, and box shadows. Learn when to use each technique and how to generate CSS code quickly.
Edit Images in Your Browser: Resize, Compress, Convert, and Extract Metadata
Learn how to handle common image editing tasks directly in your browser without installing software — resize, compress, convert formats, and inspect metadata.
CSS Generators for Modern Web Design: Gradients, Flexbox, Grid, and Shadows
Learn how to use CSS generators to quickly create gradients, flexbox layouts, grid systems, and box shadows — with the CSS code ready to copy into your project.