Color Theory & HTML Codes

Learn how web color formats, color harmonies, and contrast work together in a design.

What Are HTML Color Codes?

HTML color codes represent colors on the web using three primary formats: HEX (e.g. #2563EB), RGB (rgb(37, 99, 235)), and HSL (hsl(221, 83%, 53%)). These formats can describe the same color using different values.

  • HEX: Six-digit hexadecimal notation (RRGGBB) from 00 to FF.
  • RGB / RGBA: Decimal values from 0 to 255, plus optional alpha transparency.
  • HSL / HSLA: Hue (0–360°), Saturation (0–100%), and Lightness (0–100%), ideal for creating tints and shades.

60-30-10 Palette Rule

A classic UI design rule for applying color combinations cleanly without overwhelming users:

  • 60% Dominant Neutral: Page background and primary surfaces (e.g. slate white or deep charcoal).
  • 30% Secondary Color: Cards, sidebars, headers, and supporting containers.
  • 10% Accent Color: Primary CTA buttons, active links, badges, and key highlights.

Color Harmonies Explained

  • Complementary: Opposite hues on the color wheel (180° apart) for bold, high-contrast CTAs.
  • Analogous: Neighboring hues (±30°) for calm, cohesive interfaces.
  • Triadic: Three evenly spaced hues (120° apart) for vibrant, playful palettes.
  • Split-Complementary: Base hue paired with the two colors adjacent to its complement.
  • Monochromatic: Variations in lightness and saturation of a single hue.

Accessibility & Contrast

Always verify text contrast before shipping a palette. Under WCAG 2.1:

  • AA Normal Text: Minimum contrast ratio of 4.5 : 1.
  • AA Large Text (18pt+ / 14pt+ bold): Minimum ratio of 3.0 : 1.
  • AAA Normal Text: Enhanced contrast ratio of 7.0 : 1.
Open Contrast Checker →