Open In App

CSS hsl() Function

The hsl() function is an inbuilt function in CSS that is used to define the colors using the Hue-saturation-lightness model (HSL).

Syntax: 



hsl( hue, saturation, lightness )

Parameters: This function accepts three parameters as mentioned above and described below: 

Example: The below program illustrates the hsl() function in CSS:






<!DOCTYPE html>
<html>
 
<head>
    <title>hsl() function</title>
    <style>
        .gfg1 {
            background-color: hsl(120, 100%, 40%);
            text-align: center;
        }
         
        .gfg2 {
            background-color: hsl(120, 100%, 75%);
            text-align: center
        }
         
        .gfg3 {
            background-color: hsl(120, 100%, 20%);
            text-align: center
        }
         
        .gfg {
            font-size: 40px;
            font-weight: bold;
            color: green;
            text-align: center;
        }
         
        h1 {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <div class="gfg">GeeksforGeeks</div>
     
    <h1>The hsl() Function</h1>
 
    <p class="gfg1">Green</p>
    <p class="gfg2">Light green</p>
    <p class="gfg3">Dark green</p>
</body>
 
</html>

Output: 

Supported Browsers: The browser supported by hsl() function are listed below: 


Article Tags :