← Guides

Developer Guide

Hex Colors for Web Design

Use #RRGGBB, 3-digit shorthand, RGB, and HSL in CSS. Generate complementary, triadic, analogous, and shade palettes, then check WCAG contrast on pairs.

hex color web designcss hex colorshex to rgb hslcomplementary triadic analogouswcag contrast 4.5:1

CSS wants a color as a token: #3b82f6, rgb(59, 130, 246), or hsl(217, 91%, 60%). Those three are the same sRGB blue. Design tools often export hex; browsers compute contrast from luminance; palettes are easier to reason about in HSL where hue is an angle. /tools/color-hex converts among HEX, RGB, and HSL, with a picker that starts at #38BDF8 (rgb(56, 189, 248)).

Picking a pretty pair is not the same as reading body text on it. WCAG 2 contrast is a spec: 4.5:1 for normal text and 3:1 for large text at AA. Check pairs on /tools/contrast-checker before you freeze a palette.

#RRGGBB and 3-digit shorthand

Six-digit hex is two digits per channel, 00–FF. #000000 is black, #FFFFFF is white, #FF8000 is rgb(255, 128, 0). Three-digit hex duplicates each digit: #fff expands to #ffffff, #38b would expand to #3388bb. /tools/color-hex accepts both.

Hex is not case-sensitive in CSS. Lowercase is the usual convention in code reviews. Eight-digit hex (#RRGGBBAA) adds alpha; if you need transparency, rgba() / hsla() are often clearer in a stylesheet than hunting a hidden alpha byte.

RGB and HSL

RGB is additive channels 0–255. HSL is hue 0–360, saturation and lightness 0–100%. Lightness is the lever for tints and shades: same hue, different L. /tools/color-hex shows all three for the current color so you can paste whichever the stylesheet uses.

#3b82f6 is rgb(59, 130, 246) and hsl(217, 91%, 60%) — the site’s primary blue. The picker default #38BDF8 is a lighter sky (rgb(56, 189, 248)). Use Random to jump, Save to keep swatches in that tab, and copy from the conversion row rather than retyping.

Palettes the converter actually builds

Complementary is hue + 180. Triadic is the base plus hue + 120 and + 240. Analogous is ±30 hue around the base. Shades & tints keep hue and saturation and step lightness by −40, −20, 0, +20, +40 (clamped to 0–100). Those are the four strips on /tools/color-hex, not a marketing set of extra harmonies.

They are starting points. Complementary orange-on-blue may fail contrast. Analogous neighbors can be indistinguishable on a cheap laptop. Always run the text/background pair through /tools/contrast-checker.

WCAG contrast

WCAG 2 Success Criterion 1.4.3 (AA) requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt or 14pt bold, and the equivalent on the web). AAA is stricter (7:1 normal, 4.5:1 large). That ratio is a defined luminance calculation, not a taste poll.

Paste the foreground and background hex into /tools/contrast-checker. If the brand blue fails on white at 16px, darken it (lower HSL lightness) or keep it for large headings and buttons only. Do not “fix” contrast by telling users to zoom.

From picker to CSS

Pick once, copy the hex into custom properties: --color-brand: #3b82f6;. Derive hover states from the shade strip rather than inventing a second hue. Keep a neutrals scale (the L steps) for borders and muted text, then verify muted text still meets 4.5:1 if it is the primary reading color.

If a screenshot gives you a color you cannot sample in Figma, the native picker on /tools/color-hex is a browser <input type="color"> — close enough for CSS, not a spectrophotometer.

Common pitfalls

Using #fff on #38BDF8 for small text without checking the ratio. Mixing hex from sRGB with colors managed in Display P3 without noticing. Assuming complementary means “accessible pair” — it only means opposite hue.

Another trap: generating palettes here and then checking contrast in a tool that uses a different relative-luminance formula. Stick to /tools/contrast-checker for the pair, and keep the hex converter for conversion and harmony strips.

  • #3b82f6 = rgb(59, 130, 246).
  • Default picker #38BDF8 = rgb(56, 189, 248).
  • AA: 4.5:1 normal text, 3:1 large text (WCAG 2).

Worked examples

Primary blue conversions

Input
#3b82f6
Output
rgb(59, 130, 246) · hsl(217, 91%, 60%)

Type this into /tools/color-hex. Complementary is hue 37° (180° opposite). Triadic adds 120° and 240°.

3-digit expansion and orange

Input
#fff  and  #FF8000
Output
#ffffff  ·  rgb(255, 128, 0)

Shorthand #fff is white. #FF8000 is a pure orange with green at 128, not 255.

Frequently asked questions

What palettes does Color Hex generate?

Complementary (+180 hue), triadic (+120 and +240), analogous (±30), and five lightness steps at −40/−20/0/+20/+40. There is also Random and Save.

What is the default color on the picker?

#38BDF8, which is rgb(56, 189, 248). The site primary #3b82f6 is a separate, darker blue.

How much contrast do I need?

WCAG 2 AA: 4.5:1 for normal text, 3:1 for large text. Check pairs on /tools/contrast-checker.

Do these tools upload brand palettes?

No. /tools/color-hex and /tools/contrast-checker run in the browser. Saved swatches live in that tab until you close it.

Summary

Specify colors as hex, RGB, or HSL — /tools/color-hex converts them and builds complementary, triadic, analogous, and lightness palettes from the current hue. Then prove the text pair on /tools/contrast-checker against WCAG 4.5:1 / 3:1 before it ships.

Try it yourself

Put what you've learned into practice with our free browser-native tool.

Open Tool →