The hsl() function is an inbuilt function in CSS which 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:
- hue: This parameter is used to define the degree on the color wheel. Its value lies between 0 to 360 where 0 or 360 represents red, 120 represents green and 240 represents blue.
- saturation: This parameter is used to define the saturation where 0% represents shade of gray and 100% represents full color.
- lightness: This parameter is used to define the lightness where 0% represents black, 50% represents normal, and 100% represents white.
Below program illustrates the hsl() function in CSS:
Program:
<!DOCTYPE html> <html> <head> <title>cubic-bezier 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> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by hsl() function are listed below:
- Chrome 1.0 and above
- Internet Explorer 9.0 and above
- Firefox 1.0 and above
- Safari 3.1 and above
- Opera 9.5 and above
Recommended Posts:
- D3.js | d3.hsl() Function
- HTML | Color Styles and HSL
- How to override the CSS properties of a class using another CSS class ?
- Difference between bootstrap.css and bootstrap-theme.css
- CSS | rgb() Function
- CSS | rgba() Function
- CSS | hsla() Function
- CSS | cubic-bezier() Function
- CSS | calc() Function
- CSS | attr() Function
- CSS | linear-gradient() Function
- CSS | radial-gradient() Function
- CSS | repeating-radial-gradient() Function
- CSS | repeating-linear-gradient() Function
- CSS | animation-timing-function Property
- CSS | var() Function
- How to remove style added with .css() function using JavaScript?
- CSS | brightness() Function
- CSS | blur() Function
- CSS | contrast() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


