Technische Referenzbibliothek100% 100% Client-Side

RGB vs HEX vs HSL: Auswahl des richtigen CSS-Farbmodells

Wie Webdesigner und Frontend-Entwickler Farbmodelle für barrierefreie, wartbare UI-Systeme optimal einsetzen.

Technisches Fazit & Empfehlung

Verwenden Sie HEX für kompakte Design-Tokens in Styleguides und Figma. Verwenden Sie RGB für Bildverarbeitung und Canvas-Pixel. Verwenden Sie HSL für dynamische UI-Themes und Hover-Zustände, da Farbton, Sättigung und Helligkeit mathematisch über CSS-Variablen angepasst werden können.

Vergleichsmatrix für Funktionen & Spezifikationen

Direkter Vergleich technischer Spezifikationen
DimensionHEX (#)RGB / RGBAHSL / HSLA
Syntaxformat#6366f1 or #6366f180rgb(99, 102, 241) / rgba(...)hsl(239, 84%, 67%) / hsla(...)
Menschliche VerständlichkeitLow (Hexadecimal base-16)Medium (Red/Green/Blue 0-255)High (Angle 0-360°, % lightness)
Alpha-Transparenz8-digit hex (#rrggbbaa)rgba(r, g, b, alpha)hsla(h, s, l, alpha)
Theme-AnpassbarkeitDifficult without preprocessorDifficult to lighten/darken linearlyTrivial (Adjust lightness % directly)
Browser-Kompatibilität100% All Browsers100% All Browsers100% Modern Browsers

Architektonische Kompromisse & Merkmale

Wesentliche Stärken und Einschränkungen bei der Auswahl Ihres Standards

HSL (Hue, Saturation, Lightness)

Hauptvorteile

  • ✓Predictable color tweaks: increase L for hover states, decrease L for active states
  • ✓Ideal for CSS Custom Properties (--primary-h: 239; --primary-s: 84%;)
  • ✓Intuitive color wheel angle mapping

Kompromisse & Einschränkungen

  • ✕Perceptual lightness is not uniform across colors (pure yellow looks much brighter than pure blue at 50% lightness)

HEX

Hauptvorteile

  • ✓Shortest character footprint in CSS and HTML stylesheets
  • ✓Universally copied from Photoshop, Figma, and Illustrator

Kompromisse & Einschränkungen

  • ✕Difficult to mentally estimate the color without a visual previewer

Interaktive Tools für diesen Vergleich starten

100% private Ausführung im Browser-Speicher

Häufig Gestellte Fragen

Clear answers to common engineering questions
Why is HSL better for dark/light themes?

Because you can keep Hue and Saturation identical while simply swapping the Lightness percentage (e.g. 15% for dark mode backgrounds, 95% for light mode backgrounds).

How does HEX alpha transparency work?

In 8-digit hex like #6366f180, the last two hex digits represent alpha from 00 (0% opacity) to FF (100% opacity). 80 corresponds to roughly 50% opacity.

Offline Mode — Loaded tools run 100% locally