Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

CSS | hsla() Function

  • Last Updated : 04 Dec, 2018

The hsla() function is an inbuilt function in CSS which is used to define the colors using the Hue Saturation Lightness Alpha (HSLA) model.


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

hsla( hue, saturation, lightness, alpha )

Parameters: This function accepts four 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.
  • alpha: This parameter is used to defines the opacity and the value lies between 0.0 (fully transparent) and 1.0 (fully opaque).

Below program illustrates the hsla() function in CSS:


<!DOCTYPE html>
        <title>hsla function</title>
            .gfg1 {
                background-color:hsla(120, 100%, 40%, 0.3);
            .gfg2 {
                background-color:hsla(120, 100%, 75%, 0.3);
            .gfg3 {
                background-color:hsla(120, 100%, 20%, 0.3);
            .gfg {
            h1 {
        <div class = "gfg">GeeksforGeeks</div>
        <h1>The hsla() Function</h1>
        <p class = "gfg1">Green</p>
        <p class = "gfg2">Light green</p>
        <p class = "gfg3">Dark green</p>


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

  • Chrome 1.0 and above
  • Internet Explorer 9.0 and above
  • Firefox 3.0 and above
  • Safari 3.1 and above
  • Opera 10.0 and above

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!