Every color you see on a website, app, or digital interface is described by a code — a precise mathematical representation of exactly which point in the color space that pixel should occupy. But the same color can be expressed in multiple formats: #0D5C46, rgb(13, 92, 70), hsl(161, 75%, 21%). Which format do you use? When? Why do they exist? And how does any of this connect to the colors you choose for your design in the first place?
This guide is the complete reference for color codes and color theory as they apply to digital design. We cover every format — HEX, RGB, RGBA, HSL, HSLA, and CMYK — with worked conversion examples, explain the color theory fundamentals that help you choose colors that work together, address web accessibility contrast requirements, provide a CSS usage guide, and walk through how to use our free Color Converter tool to convert between formats and explore colors visually.
How Computers Represent Color: The Foundations
The RGB Color Model: Light as Color
Digital screens — phones, laptops, monitors, televisions — produce color by emitting light. Every pixel contains three tiny light sources: Red, Green, and Blue. By varying the intensity of each from 0 (off) to 255 (maximum brightness), screens can produce approximately 16.7 million distinct colors. This is the additive color model: you start with black (no light) and add light to create color. Combining red and green light produces yellow. Combining all three at full intensity produces white light.
This is why RGB is the native language of screens: it maps directly to the physical hardware. Every color you specify in a web browser, design tool, or image editor is ultimately reduced to RGB values before being sent to the display. All other color formats — HEX, HSL, CMYK — are alternative ways of expressing or approximating the same underlying RGB values.
The Subtractive Model: How Print Is Different
Print works on the opposite principle. Paper starts white (reflecting all light). Inks absorb (subtract) portions of the spectrum. The CMYK model — Cyan, Magenta, Yellow, and Key (Black) — works by layering transparent ink pigments that each absorb specific light wavelengths. Mixing all three colors (CMY) theoretically produces black, but in practice produces a muddy dark brown; a separate black (K) ink is required for clean, deep blacks.
This fundamental difference between additive (screen) and subtractive (print) color means that RGB colors cannot always be reproduced exactly in CMYK print. Certain highly saturated blues, greens, and oranges visible on screen fall outside the CMYK gamut — the range of colors reproducible with those inks on paper. This is why designs created for screen often look different when printed, and why professional print workflows require converting from RGB to CMYK before sending to press.
HEX Color Codes: The Web Standard
What Is a HEX Code?
A HEX color code is a 6-digit (or 3-digit shorthand) representation of an RGB color in base-16 (hexadecimal) notation, prefixed with #. The six digits split into three pairs: the first pair is Red, the second is Green, the third is Blue. Each pair represents a value from 00 (0 in decimal) to FF (255 in decimal).
For ToolWeb's brand green: #0D5C46:
0D= Red: (0 × 16) + 13 = 135C= Green: (5 × 16) + 12 = 9246= Blue: (4 × 16) + 6 = 70- RGB equivalent:
rgb(13, 92, 70)
3-Digit HEX Shorthand
When each pair in a HEX code consists of two identical digits, it can be shortened to a single digit. #FFCC00 can be written as #FC0; #112233 as #123. The browser expands each digit by doubling it — #FC0 → #FFCC00. This shorthand only works when both digits in each pair are the same; it cannot shorten arbitrary codes like #0D5C46.
8-Digit HEX with Alpha (Transparency)
Modern CSS supports an 8-digit HEX format that adds an alpha channel: #RRGGBBAA. The last two digits represent opacity from 00 (fully transparent) to FF (fully opaque). #0D5C4680 is ToolWeb green at approximately 50% opacity. This is mathematically equivalent to rgba(13, 92, 70, 0.5).
When to Use HEX
- Static colors in CSS stylesheets (backgrounds, borders, text)
- Design token definitions and brand color specifications
- Copy-pasting colors between design tools (Figma, Sketch, Adobe XD all export HEX)
- When conciseness is important (6 characters vs. up to 25 for RGBA)
RGB and RGBA: The Intuitive Format
RGB Syntax
The CSS rgb() function takes three parameters — red, green, blue — each as an integer from 0 to 255. rgb(13, 92, 70) is ToolWeb green. In CSS Level 4, commas are optional: rgb(13 92 70) is equivalent. Both syntaxes are supported in all modern browsers.
RGBA: Adding Transparency
The rgba() function adds a fourth parameter: alpha, from 0 (fully transparent) to 1 (fully opaque). rgba(13, 92, 70, 0.5) is ToolWeb green at 50% opacity. This is the most readable format for transparent colors because the opacity value (0.5) is immediately interpretable, unlike the hex equivalent (#0D5C4680) which requires mental hex-to-decimal conversion.
Practical RGB Color Reference
| Color Name | HEX | RGB | Notes |
|---|---|---|---|
| Pure Red | #FF0000 | rgb(255, 0, 0) | Maximum red channel |
| Pure Green | #00FF00 | rgb(0, 255, 0) | Maximum green channel |
| Pure Blue | #0000FF | rgb(0, 0, 255) | Maximum blue channel |
| White | #FFFFFF | rgb(255, 255, 255) | All channels maximum |
| Black | #000000 | rgb(0, 0, 0) | All channels zero |
| Medium Gray | #808080 | rgb(128, 128, 128) | Equal channels at half |
| ToolWeb Green | #0D5C46 | rgb(13, 92, 70) | Brand primary |
| Emerald | #4ADE80 | rgb(74, 222, 128) | Tailwind emerald-400 |
HSL and HSLA: The Designer's Color Model
Why HSL Exists
RGB is efficient for machines but unintuitive for humans. If you have rgb(13, 92, 70) and want a lighter version of the same color, how do you modify it? You would need to understand how each of the three channels contributes to perceived lightness — a non-obvious calculation. HSL solves this by separating color into three properties that map to how humans actually think about color:
The Three HSL Parameters
- Hue (H): The color's position on the color wheel, expressed in degrees from 0 to 360. 0° and 360° = red. 120° = green. 240° = blue. Intermediate values are the spectrum between these anchors. Hue is the answer to "what color is this?"
- Saturation (S): The intensity or purity of the color, from 0% (fully desaturated — gray) to 100% (fully saturated — the pure color). A hue at 50% saturation is a muted, pastel version. Saturation answers "how vivid is this color?"
- Lightness (L): How light or dark the color is, from 0% (black) through 50% (the pure color) to 100% (white). Lightness answers "how bright is this color?"
ToolWeb green (#0D5C46) in HSL: hsl(161, 75%, 21%). Hue 161° is a blue-green (teal/emerald range). Saturation 75% is highly vivid. Lightness 21% is quite dark — a deep forest green.
The Power of HSL in Design Systems
HSL's true advantage is in design systems and component libraries. Consider these operations that are trivial in HSL but require calculation in RGB:
- Create a lighter shade: Increase L —
hsl(161, 75%, 40%)is a lighter green - Create a muted/pastel version: Decrease S —
hsl(161, 30%, 21%)is a desaturated, muted green - Find the complementary color: Add 180° to H —
hsl(341, 75%, 21%)is a deep red-pink - Create a hover state: Increase L by 10% — a trivial change in HSL, a complex calculation in RGB
/* Design system using HSL — easy to maintain */
:root {
--brand-hue: 161;
--brand-sat: 75%;
--color-primary: hsl(var(--brand-hue), var(--brand-sat), 21%);
--color-primary-light:hsl(var(--brand-hue), var(--brand-sat), 40%);
--color-primary-pale: hsl(var(--brand-hue), 30%, 90%);
--color-primary-dark: hsl(var(--brand-hue), var(--brand-sat), 12%);
}
CMYK: The Print Standard
CMYK Syntax and Values
CMYK expresses color as four percentage values: Cyan, Magenta, Yellow, and Key (Black), each from 0% to 100%. cmyk(86%, 0%, 24%, 64%) approximates ToolWeb green in print. CMYK is not natively supported in CSS — it is used exclusively in print workflows through design software (Adobe Illustrator, InDesign, Photoshop) and sent to printers as ICC-profiled CMYK PDFs.
The RGB-to-CMYK Conversion Problem
Converting between RGB and CMYK is not a simple mathematical formula — it involves color profiles (ICC profiles) that account for the specific characteristics of the inks and paper being used. A CMYK value calculated purely mathematically (without a profile) gives an approximation, not a press-accurate result. For professional print work, always let a profiled conversion in Adobe software or your print provider's preflight tool handle the conversion — never rely on online calculators for print-critical color accuracy.
| Color Model | Format | Use Case | Transparency Support |
|---|---|---|---|
| HEX | #RRGGBB or #RRGGBBAA | Web CSS (static colors) | ✅ (8-digit) |
| RGB | rgb(R, G, B) | Web CSS (programmatic) | ❌ |
| RGBA | rgba(R, G, B, A) | Web CSS (with transparency) | ✅ |
| HSL | hsl(H, S%, L%) | Design systems, theming | ❌ |
| HSLA | hsla(H, S%, L%, A) | Design systems + transparency | ✅ |
| CMYK | cmyk(C%, M%, Y%, K%) | Print only; not in CSS | ❌ |
Color Theory Fundamentals for Digital Designers
The Color Wheel and Harmony Schemes
Color harmony refers to combinations of colors that are aesthetically pleasing because of their geometric relationship on the color wheel. These are not arbitrary preferences — they are patterns identified through centuries of art and design practice. The major harmony schemes:
| Harmony Type | Definition | Effect | Best For |
|---|---|---|---|
| Monochromatic | One hue, multiple lightness/saturation values | Cohesive, sophisticated, restrained | Professional, minimal brands |
| Analogous | 2–4 adjacent hues on the wheel (within 60°) | Harmonious, calm, natural | Nature brands, wellness, lifestyle |
| Complementary | Two opposite hues (180° apart) | High contrast, energetic, attention-grabbing | CTAs, sports, retail promotions |
| Split-complementary | A hue + two colors adjacent to its complement | High contrast without direct clash | Balanced vibrance |
| Triadic | Three hues equally spaced (120° apart) | Vibrant, playful, balanced | Children's brands, creative industries |
| Tetradic / Square | Four hues equally spaced (90° apart) | Rich variety; complex to balance | Advanced design systems |
Color Psychology in Web Design
Color associations vary significantly across cultures, but some patterns are broadly consistent in Western digital product design:
| Color | Common Associations | Common Use Cases |
|---|---|---|
| Blue | Trust, stability, calm, professionalism | Banks, social media, healthcare, tech (Facebook, PayPal, LinkedIn) |
| Green | Growth, nature, health, success, go/yes | Finance apps (Robinhood), health, sustainability, CTAs |
| Red | Urgency, danger, passion, energy | Sale labels, error states, food delivery, sports |
| Orange | Enthusiasm, creativity, affordability, warmth | E-commerce discounts, food, creative tools |
| Yellow | Optimism, caution, attention, warmth | Warnings, highlights, children's brands |
| Purple | Luxury, creativity, spirituality, mystery | Premium brands, beauty, gaming |
| Black | Sophistication, power, luxury, elegance | High fashion, premium tech, editorial |
| White | Cleanliness, simplicity, space, health | Medical, minimal design, Apple products |
Color Accessibility: WCAG Contrast Ratios
Approximately 8% of men and 0.5% of women have some form of color vision deficiency (commonly called color blindness). Web accessibility standards require that text be readable regardless of color perception. The Web Content Accessibility Guidelines (WCAG) define minimum contrast ratios between text and its background:
| WCAG Standard | Normal Text | Large Text (18pt+ or 14pt bold) | UI Components |
|---|---|---|---|
| AA (minimum) | 4.5:1 | 3:1 | 3:1 |
| AAA (enhanced) | 7:1 | 4.5:1 | — |
A white text (#FFFFFF) on ToolWeb green (#0D5C46) has a contrast ratio of approximately 7.2:1, which passes both AA and AAA for normal text. Black on white achieves the maximum 21:1 ratio. To check any color pair, tools like WebAIM's Contrast Checker or the browser DevTools accessibility panel calculate the ratio automatically.
⚠️ Common accessibility mistake: Light gray text on a white background (e.g., #AAAAAA on #FFFFFF) has a contrast ratio of approximately 2.3:1 — failing WCAG AA for normal text. Many "clean" minimal designs fail this check. Always verify your text/background color pairs before launch.
CSS Color Usage Guide (2026)
All CSS Color Formats at a Glance
/* All represent ToolWeb green (#0D5C46 = rgb(13,92,70) = hsl(161,75%,21%)) */
/* HEX */
color: #0D5C46;
/* RGB */
color: rgb(13, 92, 70);
/* RGB (CSS Level 4 — no commas) */
color: rgb(13 92 70);
/* RGBA — 50% transparent */
color: rgba(13, 92, 70, 0.5);
/* HSL */
color: hsl(161, 75%, 21%);
/* HSLA — 50% transparent */
color: hsla(161, 75%, 21%, 0.5);
/* 8-digit HEX — 50% transparent */
color: #0D5C4680;
/* CSS custom properties (recommended for design systems) */
:root { --brand-green: #0D5C46; }
.element { color: var(--brand-green); }
/* Modern: oklch (perceptually uniform, 2024+) */
color: oklch(38% 0.09 161);
Choosing the Right Format for Your Project
- Simple static styles: HEX — shortest, universally supported, easy to copy
- Transparency needed: RGBA or HSLA — both work; RGBA is more widely understood
- Design system / component library: HSL with CSS custom properties — enables programmatic variation and theme switching
- Print design: CMYK — only use in professional design software, not CSS
- Advanced accessibility / color science: oklch / lab — the future standard for perceptually uniform color manipulation
How to Use ToolWeb's Free Color Converter
What the Tool Converts
ToolWeb's Color Converter converts between HEX, RGB, and HSL — the three formats most commonly needed for web and digital design work. It also includes a visual color picker so you can select colors interactively and instantly see all three format equivalents.
Step 1 — Open the Color Converter
Navigate to toolweb.info/color-converter.html. No account, no download. The tool loads with ToolWeb's brand green as the default color.
Step 2 — Pick a Color Visually
Click the color picker (the tall colored rectangle at the top of the tool) to open your browser's native color selection interface. Choose any color you want to work with — drag across the gradient to find the hue, saturation, and lightness you need.
Step 3 — Read All Three Format Outputs
As you select a color, the HEX, RGB, and HSL values update instantly in the three display panels. Each has a Copy button — click it to copy that format directly to your clipboard for pasting into your CSS, design tool, or documentation.
Step 4 — Convert a Specific HEX Code
If you have a specific HEX code you want to convert (from a brand guideline or a design file), you can use the color picker to enter it manually. In most browsers, the native color picker has a hex input field — type or paste your code there and the tool updates all three outputs immediately.
Step 5 — Explore Color Variations
Use the lightness slider in the color picker to create lighter or darker versions of your color, then copy each variation's HEX code. This is a fast way to build a monochromatic palette from a single brand color.
🎨 Convert Any Color Instantly
ToolWeb's free Color Converter converts between HEX, RGB, and HSL with a live visual picker. Perfect for designers, developers, and anyone working with digital color. No sign-up required.
🎨 Open Color ConverterFAQ — Color Codes Answered
What is the difference between HEX and RGB color codes?
HEX and RGB represent the same color information in different formats. RGB uses three decimal numbers (0–255) for Red, Green, Blue: rgb(255, 99, 71). HEX uses base-16 pairs prefixed with #: #FF6347. FF = 255, 63 = 99, 47 = 71. They are mathematically interchangeable with exact conversion — HEX is more compact; RGB is more intuitive for adjusting individual channels.
What does HSL stand for in color codes?
Hue, Saturation, Lightness. Hue = position on the color wheel (0–360°: 0=red, 120=green, 240=blue). Saturation = intensity (0% gray to 100% pure color). Lightness = brightness (0% black, 50% pure color, 100% white). HSL is preferred for design systems because each parameter maps directly to a human-understandable color property.
What is the difference between RGB and CMYK?
RGB is an additive light model for screens — mixing red, green, and blue light produces all colors, with full intensity producing white. CMYK is a subtractive ink model for print — layering cyan, magenta, yellow, and black inks absorbs light wavelengths to produce color. The two have different gamuts (color ranges), so RGB colors cannot always be exactly reproduced in CMYK print.
How do I convert HEX to RGB?
Split the 6-digit hex into three pairs and convert each from base-16 to decimal. For #1A8466: 1A = (1×16)+10 = 26; 84 = (8×16)+4 = 132; 66 = (6×16)+6 = 102. Result: rgb(26, 132, 102). ToolWeb's Color Converter automates this for any color instantly.
What is color contrast ratio and why does it matter for accessibility?
Contrast ratio measures luminance difference between text and background (1:1 = no contrast; 21:1 = maximum). WCAG 2.1 AA requires 4.5:1 for normal text, 3:1 for large text. AAA requires 7:1. These standards ensure readability for users with low vision or color deficiency. Approximately 8% of men have some form of color vision deficiency.
What are complementary colors?
Colors directly opposite on the color wheel (180° apart). Common pairs: Red/Green, Blue/Orange, Yellow/Violet. They create maximum visual contrast and make each other appear more intense. In web design, complementary schemes work well for calls-to-action. Pair a saturated version of one with a muted version of its complement for a more sophisticated result than full-saturation clash.
What color format should I use in CSS?
HEX for static colors (shortest, most common). RGBA when you need transparency. HSL with CSS custom properties for design systems (most maintainable — adjust one value to change all derived colors). CMYK is not supported in CSS and should only be used in print design software.
How do I pick colors that work well together?
Use established color harmony schemes from the color wheel: Complementary (two opposite colors — high contrast), Analogous (adjacent colors — harmonious), Triadic (three evenly spaced colors — balanced vibrance), or Monochromatic (one hue, varied lightness — cohesive). Start with your primary hue, then derive supporting colors using a harmony scheme. ToolWeb's Color Converter helps you explore these visually.
What is the #RRGGBBAA format?
An 8-digit HEX that adds two digits for the alpha (opacity) channel. #0D5C4680 = ToolWeb green at ~50% opacity (80 hex = 128 decimal = 128/255 ≈ 50%). Supported in all modern browsers but less readable than rgba() notation for transparency, because the hex math is less intuitive than a 0–1 decimal.