Three Notations, One Pixel: Why CSS Has So Many Color Formats
Open a Figma file, inspect a browser stylesheet, and read a JavaScript canvas script, and you will see the exact same bright blue written three different ways: #3B82F6, rgb(59, 130, 246), and hsl(217, 91%, 60%). Each notation describes the exact same sRGB screen color, yet each makes a different job easier. HEX packs tightly into config files and design tokens. RGB mirrors how monitor subpixels and image buffers store values. HSL lets you darken a button on hover without reaching for a calculator.
This color picker and converter keeps all three formats synchronized as you drag sliders or type values, adds an independent Alpha opacity slider, computes live WCAG contrast scores against white and black text, and generates ten ready to copy tint and shade variations straight from your browser.
Reading 3, 6, and 8 Digit HEX Codes (and One Common Bug)
Hexadecimal color codes are shorthand for three 8 bit numbers written in base 16 (digits 0 through 9 and letters A through F). After the leading # symbol, pairs of digits encode Red, Green, and Blue from 00 (0) up to FF (255). In #3B82F6, 3B equals 59 red, 82 equals 130 green, and F6 equals 246 blue.
Three digit shorthand such as #38F expands by doubling each digit into #3388FF. Type a 3 digit code into the HEX box above and the converter expands it immediately into full RGB and HSL numbers.
Modern browsers also support 8 digit HEX strings for transparency, such as #3B82F680, where the trailing 80 (128 out of 255) gives roughly 50 percent opacity. Notice one sneaky cross platform catch here: CSS puts the alpha pair at the end (#RRGGBBAA), whereas Android XML and Flutter place alpha at the front (#AARRGGBB). Pasting an Android color token directly into a CSS stylesheet either shifts every channel off by a byte or renders the wrong transparency completely. When moving colors from mobile codebases to the web, move those first two hex characters to the end before pasting.
When to Pick RGB vs HSL in Real Stylesheets
Deciding between RGB and HSL comes down to whether you are matching hardware math or designing interactive states.
| Format | Channel Ranges | Best Used For |
|---|---|---|
| HEX / 8 Digit HEX | 00 to FF per channel |
Compact brand tokens, Tailwind config files, quick copy and paste |
| RGB / RGBA | R, G, B 0 to 255; A 0 to 1 |
Canvas graphics, image pixel math, semi transparent overlays |
| HSL / HSLA | Hue 0 to 360; S & L 0% to 100% |
Hover states, muted surfaces, light and dark UI theme variants |
Suppose a designer hands you #3B82F6 and asks for a slightly darker active press state and a softer pale tint for an alert banner. Staring at 3B82F6 gives almost no intuitive clue which characters to nudge. Look at the synced HSL boxes instead: 217 degrees hue, 91% saturation, 60% lightness. Drop Lightness from 60% to 48% for a rich pressed button, or lift Lightness to 94% for a crisp sky blue badge background while keeping the exact same hue angle.
One quick note on CSS syntax: older stylesheets wrote rgb() for opaque colors and rgba() whenever an alpha decimal appeared, and the output cards above follow that familiar rgba() and hsla() pattern for broad compatibility. Modern CSS Color Level 4 lets rgb() and hsl() accept alpha directly too, and also supports space separated syntax such as rgb(59 130 246 / 0.5) if your project prefers it.
How Alpha Transparency Changes WCAG Contrast
Drag the Alpha slider below 1.00 and watch two things happen inside the tool. First, the native OS color picker swatch ignores transparency because standard HTML <input type="color"> controls only hold opaque 6 digit colors, so this tool keeps your alpha value separate and preserves it across edits. Second, the preview box overlays your translucent color on top of a checkerboard pattern, and the WCAG contrast badge recalculates live.
Calculating contrast on a semi transparent background requires assuming what sits behind it. This converter composites your translucent RGBA color against a white #FFFFFF backdrop before measuring relative luminance, then compares that blended surface against pure white and pure black text:
- Green dot (7.00:1 or higher): Meets WCAG AAA contrast for normal body text against the winning light or dark foreground color.
- Yellow dot (4.50:1 to 6.99:1): Passes WCAG AA for normal body text and AAA for large headings (18pt or bold 14pt).
- Red dot (below 4.50:1): Fails standard WCAG AA normal text contrast even with the better text color selected. Avoid putting small body copy or form labels directly on top of that background unless you raise contrast, or limit it to large bold display text (which passes AA down to 3.00:1) and decorative borders.
Keep in mind that if you place a semi transparent button or card over a dark hero photo or charcoal dark mode surface instead of white, your real contrast ratio will differ from the white composited preview. Always test translucent overlays against the darkest and lightest surfaces they can actually sit on.
Advertisement
Sampling Colors Off Your Screen and Building UI Scales
When you want to inspect a color from an existing mockup or browser tab, clicking the native swatch in the top left opens your operating system color dialog. On modern Chromium desktop browsers such as Chrome and Edge (as well as macOS system pickers), that dialog includes an eyedropper icon that lets you sample any pixel on screen and load its exact RGB and HSL equivalents immediately.
Below the main preview, the Lighter Tints and Darker Shades strips step your current HSL lightness cleanly in equal sixths toward pure white and pure black. Clicking any tile copies its HEX code straight to your clipboard, giving you an instant scale for CSS custom properties: light tints work cleanly for subtle callout backgrounds and focus halos, while darker shades handle hover borders, pressed buttons, and high contrast text on light cards.
Notice that the CSS Variable card automatically formats --color-primary: #3B82F6; so you can drop your converted shade straight into a stylesheet. Once you have nailed down one primary brand color here and want a full five swatch theme around it, take your HEX code over to the Color Palette Generator. Or if you want to blend two shades smoothly across a hero banner or button surface, plug both HEX values into the CSS Gradient Generator.