Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS hsl() Function

CSS hsl() Function

CSS Functions CSS Functions

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.

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 CSS Functions