CSS hsl() Function
Example
Define an HSL color:
#p1
{
background-color:
hsl
(
120
,
100
%
,
50
%
)
;
}
/*
Green
*/
#p2
{
background-color:
hsl
(
120
,
100
%
,
75
%
)
;
}
/*
Light green
*/
#p3
{
background-color:
hsl
(
120
,
100
%
,
25
%
)
;
}
/*
Dark green
*/
#p4
{
background-color:
hsl
(
120
,
60
%
,
70
%
)
;
}
/*
Soft green
*/
Try it »
Definition and usage
The hsl() function defines a color using hue, saturation, and lightness.
HSL stands for Hue, Saturation, Lightness.
- **Hue (H)** is the basic property of a color, what we normally call the color name, such as red, yellow, and so on.
- **Saturation (S)** refers to the purity of a color; the higher it is, the purer the color, and the lower it is, the grayer it becomes, with values from 0-100%.
- Lightness (L), from 0-100%; increasing lightness makes the color move toward white, decreasing it makes the color move toward black.
HSL is a representation of points in the RGB color model in cylindrical coordinates. Both representations aim to be more intuitive than RGB, which is based on a Cartesian coordinate geometry structure.
Supported version: CSS3

Browser support
The numbers in the table indicate the first browser version that supports the function.
| function | |||||
|---|---|---|---|---|---|
| hsl() | 1.0 | 9.0 | 1.0 | 3.1 | 9.5 |
CSS Syntax
hsl(hue, saturation, lightness)
| Value | Description |
|---|---|
| hue - Hue | Defines the hue (0 to 360) - 0 (or 360) is red, 120 is green, 240 is blue |
| saturation - Saturation | Defines saturation; 0% is gray, 100% is full color |
| lightness - Lightness | Defines lightness; 0% is dark, 50% is normal, 100% is white |
CSS Functions