HSL stands for Hue, Saturation, and Lightness. It is a human-friendly color model designed to make color selection and adjustments more intuitive than RGB. Instead of thinking in terms of red, green, and blue channel values, HSL allows designers and developers to reason about color in a way that closely matches human perception.
The HSL color model represents colors using three components:
In CSS, HSL is written as:
hsl(hue, saturation%, lightness%)
```
---
## 1. Hue (H)
Hue represents the **type of color**. It is measured in degrees around a circular color wheel.
- Range: `0° – 360°`
- The wheel wraps around, so `360°` is the same as `0°`
Common hue values:
- `0°` → Red
- `60°` → Yellow
- `120°` → Green
- `180°` → Cyan
- `240°` → Blue
- `300°` → Magenta
Example:
```css
color: hsl(0, 100%, 50%); /* Red */
color: hsl(120, 100%, 50%); /* Green */
color: hsl(240, 100%, 50%); /* Blue */
Think of hue as choosing a position on a color wheel.
Saturation controls the intensity or purity of the color.
0% – 100%0% means no color at all (grayscale)100% means full, vivid colorExamples:
color: hsl(200, 0%, 50%); /* Gray */
color: hsl(200, 50%, 50%); /* Muted blue */
color: hsl(200, 100%, 50%); /* Vibrant blue */
Lower saturation results in washed-out or pastel-like colors, while higher saturation produces bold and vibrant colors.
Lightness defines how light or dark a color is.
0% – 100%0% → Black50% → Normal color100% → WhiteExamples:
color: hsl(30, 100%, 0%); /* Black */
color: hsl(30, 100%, 50%); /* Orange */
color: hsl(30, 100%, 100%); /* White */
Adjusting lightness is especially useful for creating hover states, shadows, and UI depth.
HSL is preferred in many design systems because:
Example: generating lighter and darker versions of the same color:
--primary: hsl(220, 90%, 56%);
--primary-light: hsl(220, 90%, 66%);
--primary-dark: hsl(220, 90%, 46%);
| Feature | RGB | HSL | | ----------------------- | ------- | ------- | | Human-friendly | No | Yes | | Easy brightness control | Hard | Easy | | Color harmony | Manual | Natural | | UI theming | Complex | Simple |
RGB is better suited for hardware-level color representation, while HSL is ideal for design systems and UI development.
Example hover effect:
.button {
background: hsl(210, 90%, 50%);
}
.button:hover {
background: hsl(210, 90%, 45%);
}
When adjusting colors using HSL:
HSL provides a powerful and intuitive way to work with colors. By separating color type, intensity, and brightness, it enables developers and designers to create consistent, scalable, and accessible color systems with ease.
If you work on modern UI, design systems, or CSS-heavy applications, mastering HSL is a valuable skill.