Why #3B82F6 Looks Different on Every Screen: The Complete HEX, RGB & HSL Color Conversion Guide
Your designer sent #3B82F6 but your CSS needs rgb() — or your Figma uses HSL. Here's everything you need to know about color code formats, when to use each one, and how to convert between them instantly.
It starts the same way every time. Your designer drops a Figma link, and the primary button is #3B82F6. You copy it into your CSS file — but then the backend engineer asks for the RGB value because their CSS-in-JS library works differently. And the marketing team wants the HSL version for the brand guidelines doc. Same color, three different requests, three different formats. This guide sorts all of that out.
What You'll Learn in This Post
- ✅How HEX, RGB, and HSL work — and when each format is the right choice
- ✅A comparison table so you can pick the right format at a glance
- ✅CSS tips, palette creation strategies, and common color conversion pitfalls
HEX, RGB, and HSL: What's Actually Different?
All three formats describe the same thing — a color on screen — but they use different mental models to do it. HEX uses hexadecimal shorthand that web browsers have understood since the 1990s. RGB talks to you in the language of light, mixing red, green, and blue at different intensities. HSL thinks like a painter: what hue is it, how vivid is it, how light or dark?
| Format | Example | Range | Best For |
|---|---|---|---|
| HEX | #3B82F6 | 00–FF per channel | HTML, CSS, design handoff |
| RGB | rgb(59, 130, 246) | 0–255 per channel | CSS animations, JS color math |
| HSL | hsl(217, 91%, 60%) | H: 0–360, S/L: 0–100% | Design systems, palette generation |
| RGBA | rgba(59, 130, 246, 0.8) | Same as RGB + alpha 0–1 | Transparency in CSS |
| HSL with alpha | hsla(217, 91%, 60%, 0.8) | Same as HSL + alpha | Transparent design system tokens |
Understanding HEX: The Web Standard
HEX (hexadecimal) is the lingua franca of web color. It packs three 8-bit values — red, green, blue — into six characters after the hash symbol. Each pair of characters represents one channel from 00 (none) to FF (full intensity). So #3B82F6 breaks down as: red = 3B (59 in decimal), green = 82 (130), blue = F6 (246).
You'll also see shorthand HEX like #FFF or #03F — these expand by doubling each digit (#FFFFFF, #0033FF). It's the same color, just fewer characters. One thing HEX cannot natively express is transparency. For that, you need 8-digit HEX like #3B82F6CC, or you switch to RGBA.
Quick sanity check for HEX values
If all six characters are pairs of the same digit — #AABBCC — the color will be muted and gray-leaning. High contrast colors (very light or very dark) tend to have lots of 0s and Fs. Mid-range colors like #3B82F6 sit in the middle of that spectrum.
RGB: The Format CSS Engineers Actually Prefer
RGB stands for Red, Green, Blue — each channel runs from 0 to 255, giving you 16.7 million possible combinations. In CSS, it looks like rgb(59, 130, 246). The advantage over HEX is that it's easier to manipulate programmatically. Want to reduce the red channel by 20? Just subtract from the first number. Want to fade a color in JavaScript? RGBA makes that trivial: rgba(59, 130, 246, 0.5) is 50% transparent.
/* HEX — clean, compact */
.button { background: #3B82F6; }
/* RGB — easy to animate */
.button { background: rgb(59, 130, 246); }
/* RGBA — transparent overlay */
.overlay { background: rgba(59, 130, 246, 0.15); }
/* CSS custom property with HSL — most maintainable */
:root { --brand-hue: 217; }
.button { background: hsl(var(--brand-hue), 91%, 60%); }
.button:hover { background: hsl(var(--brand-hue), 91%, 50%); }HSL: The Format Designers Wish Everyone Used
HSL (Hue, Saturation, Lightness) is the most human-readable color format. Hue is a number from 0 to 360 representing position on the color wheel — 0 is red, 120 is green, 240 is blue. Saturation controls how vivid the color is (0% is grayscale, 100% is full color). Lightness controls how light or dark it is (0% is black, 100% is white, 50% is the 'true' color).
This structure makes HSL incredibly powerful for design systems. Want a lighter version of your brand blue? Keep hue and saturation the same, bump lightness to 80%. Want a hover state that's slightly darker? Drop lightness by 10 points. No hex math, no guessing — just intuitive adjustments.
The CSS variable trick that makes design systems maintainable
Store your hue as a CSS custom property: --brand-hue: 217. Then use hsl(var(--brand-hue), 91%, 60%) for your primary color, hsl(var(--brand-hue), 91%, 45%) for the hover state, and hsl(var(--brand-hue), 30%, 95%) for a light background tint. Change one variable, the whole palette updates.
How to Convert Between HEX, RGB, and HSL
HEX to RGB conversion is straightforward: split the six characters into three pairs, convert each from base-16 to base-10. #3B82F6 → (0x3B, 0x82, 0xF6) → (59, 130, 246). RGB to HSL is more involved — you need to normalize the values, find the min and max, then calculate hue angle, saturation, and lightness through a series of conditional formulas. Most developers don't do this by hand, and they shouldn't.
Try this tool now:
Color Picker & Converter →Building a Color Palette That Actually Works
A professional color palette needs more than a primary color. You need a full range of shades for backgrounds, borders, text, and interactive states. The cleanest way to do this is with HSL — fix your hue and saturation, then generate a scale of lightness values from 95% (very light background) down to 20% (very dark text).
- 50: hsl(217, 91%, 97%) — page background, very light tint
- 100: hsl(217, 91%, 93%) — card backgrounds, subtle fills
- 200: hsl(217, 91%, 85%) — borders, dividers
- 300: hsl(217, 91%, 75%) — disabled states, placeholder text
- 400: hsl(217, 91%, 65%) — secondary actions, less prominent elements
- 500: hsl(217, 91%, 60%) — primary brand color (#3B82F6 equivalent)
- 600: hsl(217, 91%, 50%) — hover states, active states
- 700: hsl(217, 91%, 40%) — pressed states, strong emphasis
- 800: hsl(217, 91%, 30%) — dark backgrounds, inverted text
- 900: hsl(217, 91%, 20%) — maximum contrast, dark mode primary
Color contrast affects accessibility
WCAG AA standard requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text against its background. #3B82F6 on white (#FFFFFF) has a contrast ratio of about 3.0:1 — it passes for large text but fails for body copy. Use shade 700 or 800 on white for accessible body text, and always test with a contrast checker before shipping.
When to Use Which Format in Real Projects
In practice, the format you use depends on context. Design handoff documents and HTML attributes work best with HEX — it's compact and universally understood. CSS custom properties and Tailwind config files pair well with HSL because you can construct dynamic values from component variables. JavaScript color manipulation is cleanest with RGB or RGBA numbers. And for SVG fill attributes or email HTML, HEX is still the safest choice.
Frequently Asked Questions
Why does my color look slightly different between Figma and the browser?
Color rendering varies between applications due to color profile settings. Figma works in sRGB by default, but macOS screens often use Display P3, which has a wider gamut. The hex values are technically identical, but they may render with subtle differences depending on the device's color management. The safest approach is to compare colors on the exact target device and browser.
What does the alpha channel in RGBA or HSLA actually do?
The alpha channel controls transparency. A value of 1 is fully opaque (same as no alpha), 0 is fully transparent (invisible), and values between 0 and 1 are semi-transparent. rgba(59, 130, 246, 0.5) means the color is 50% see-through — the background beneath it will show through at half strength.
Is there a 4-digit or 8-digit HEX format?
Yes. 4-digit HEX (like #F06A) is shorthand for 8-digit HEX with transparency — each character doubles like in 3-digit HEX. 8-digit HEX (like #3B82F6CC) adds an alpha channel at the end, where CC = 80% opacity. This format is supported in all modern browsers but less commonly known.
Does it matter if HEX letters are uppercase or lowercase?
It doesn't matter for functionality — #3b82f6 and #3B82F6 are identical. However, most style guides enforce one convention for consistency. ESLint and stylelint rules can automatically enforce lowercase (#3b82f6) or uppercase, depending on your team's preference.
How do I get a color code from an existing website?
Open your browser DevTools (F12 on most browsers), click the Elements tab, select the element with the color, and look at its CSS in the Styles panel. You can click on the color swatch to open a color picker that converts between HEX, RGB, and HSL on the spot. For colors in images, use our Color Picker tool to upload and sample any pixel.
Color Picker & Converter
Convert HEX to RGB to HSL instantly. Generate color palettes, sample colors from images, and copy CSS-ready values in one click.
Open Color Picker →▶Try the tools from this article
Minjae
Developer & tech writer. Deep dives into dev tools and file conversion technology.
Found this helpful? Get new guide alerts
No spam. Unsubscribe anytime. · By subscribing, you agree to our Privacy Policy.