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

CSS hsla() Function

CSS hsla() Function

CSS Functions CSS Functions

Example

Define an HSL color with transparency:

#p1

{

background-color:

hsl

(

120

,

100

%

,

50

%

,

0.3

)

;

}

/*

Green

*/

#p2

{

background-color:

hsl

(

120

,

100

%

,

75

%

,

0.3

)

;

}

/*

Light green

*/

#p3

{

background-color:

hsl

(

120

,

100

%

,

25

%

,

0.3

)

;

}

/*

Dark green

*/

#p4

{

background-color:

hsl

(

120

,

60

%

,

70

%

,

0.3

)

;

}

/*

Soft green

*/

Try it »


Definition and usage

The hsla() function defines a color using hue, saturation, lightness, and alpha.

HSLA stands for Hue, Saturation, Lightness, Alpha.

Supported version: CSS3


Browser support

The numbers in the table indicate the first browser version that supports the function.

function
hsla() 1.0 9.0 1.0 3.1 9.5

CSS Syntax



hsla(hue, saturation, lightness, alpha)

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
alpha - Alpha Defines alpha: 0 (fully transparent) to 1 (fully opaque)

CSS Functions CSS Functions