HTML HSL Color

HSL is an alternative representation of the RGB color model where HSL is an acronym for Hue, saturation, and lightness.

If an extra alpha channel (opacity) is specified with HSL, the color model is called HSLA. It is an extension of HSL.

In HTML, different HSL values can also define different colors.

Syntax
hsl(hue, saturation, lightness)

Below is an HSL color generator. Set different values for Hue, Saturation and Lightness to make different colors.

 

Hue

190

Saturation

100%

Lightness

50%
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML HSL Color Example</title> </head>
<body>

<h1 style="background-color:hsl(0,100%,50%);">Background Color is set by value hsl(0,100%,50%)</h1>
<h1 style="background-color:hsl(160,60%,40%);">Background Color is set by value hsl(160,60%,40%)</h1>
<h1 style="background-color:hsl(260,70%,60%);">Background Color is set by value hsl(260,70%,60%)</h1>

</body>
</html>

Here the value of hue can be set from 0 to 360 where 0 represents the red color, 120 represents the green color and 240 represents the blue color.

The value of saturation and lightness is provided in percentage. In the case of saturation value, 0% is the shade of gray color and 100% is the complete color.

It means that when the saturation is 0%, the shade of gray is added to the hue while when the saturation is 100% shade of gray is not added to the hue.

In the case of lightness, if the value is set to 0% then it is for the black color.

A lightness value of 100% defines the white color.

Color Name HSL Code
Red hsl(0,100%,50%)
Green hsl(120,100%,50%)
Blue hsl(240,100%,50%)
White hsl(0,100%,100%)
Black hsl(0,100%,0%)
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML HSL Color Example</title> </head>
<body>

<h1 style="background-color:hsl(0,100%,50%);">Red Background Color</h1>
<h1 style="background-color:hsl(120,100%,50%);">Green Background Color</h1>
<h1 style="background-color:hsl(240,100%,50%);">Blue Background Color</h1>
<h1 style="background-color:hsl(0,100%,100%);">White Background Color</h1>
<h1 style="background-color:hsl(0,100%,0%);">Black Background Color</h1>

</body>
</html>

Saturation

Saturation is the intensity of the color.

When the saturation is set to 100%, we can see the full color.

When it is set to 50% the color will have a 50% shade of gray.

When the saturation is set to 0% the color disappears and only a gray shade is visible.

hsl(240 ,100%, 30%)
hsl(240 ,50%, 30%)
hsl(240 ,0%, 30%)

Lightness

The lightness value indicates the percentage of light addition to the color.

100% light addition makes the color white.

A 50% light addition makes the color representation normal. A 0% light addition makes the color black.

hsl(240 ,100%, 100%)
hsl(240 ,100%, 50%)
hsl(240 ,100%, 0%)

HTML HSLA Color

HSLA is an extension of HSL color with an alpha channel which sets an extra parameter for opacity.

HSLA Color
hsla(hue, saturation, lightness, alpha)

Below is an HSLA color generator. Mix Hue, Saturation, Lightness and Alpha to make a new color.

 

Hue

128

Saturation

100%

Lightness

50%

Alpha

0.5

The alpha parameter can be set from 0.0 to 1.0. Where the value 0 indicates that the color is fully transparent and 1.0 indicates that the color is no more transparent.

The color transparency decreases gradually from the value 0 to 1.

hsla(240 ,100%, 50%, 1)
hsla(240 ,100%, 50%, 0.8)
hsla(240 ,100%, 50%, 0.6)
hsla(240 ,100%, 50%, 0.4)
hsla(240 ,100%, 50%, 0.2)
hsla(240 ,100%, 50%, 0.1)

  • Disclaimer: ResultUniversity.com is an independent private website and it is in no way affiliated to any Indian Government official website. The sole purpose of this website is to provide notifications regarding the latest results published. Though utmost care is being taken, we can not guarantee 100% correctness of information. Using this website confirms that you agree to all the terms and conditions.