
February 21, 2023
Understanding HSL format

Marcel Miłosz
Read time: 5 min.
When it comes to styling web pages, color plays a crucial role in creating an appealing and aesthetically pleasing design. CSS provides various color formats to choose from, including RGB, HEX, and HSL. While RGB and HEX are widely used, HSL is gaining popularity because of its intuitive and flexible nature.
HSL stands for Hue, Saturation, and Lightness, and it allows you to define a color based on its hue, saturation, and lightness levels. In this blog, we will dive deeper into the HSL format and how it works.
Understanding HSL values
Hue: Hue represents the color itself, ranging from 0 to 360 degrees on the color wheel. The values for hue are red (0), yellow (60), green (120), cyan (180), blue (240), magenta (300), and red again (360).
Saturation: Saturation determines the purity or intensity of the color, ranging from 0% to 100%. A saturation level of 0% produces a grayscale color, while 100% represents the most vivid, pure form of the color.
Lightness: Lightness determines the brightness of the color, ranging from 0% (black) to 100% (white). It is important to note that lightness is not the same as brightness, as it refers to the amount of light reflected by the color rather than the overall luminosity.
Using HSL in CSS
To use HSL in CSS, you can specify the hue, saturation, and lightness values using the hsl() function. Here is an example:
background-color: hsl(210, 50%, 75%);
In this example, the hue value is 210 (a blue-green color), the saturation value is 50%, and the lightness value is 75%. You can also use HSL values in combination with other CSS properties, such as opacity, to create a variety of effects. Here's an example:
background-color: hsla(210, 50%, 75%, 0.5);
In this example, the "a" in "hsla" stands for "alpha" and the fourth value represents the opacity level (ranging from 0 to 1). In this case, the background color will have a blue-green hue with 50% saturation and 75% lightness, and an opacity level of 0.5 (semi-transparent).
HSL is a versatile and flexible color format that can be used to create a wide range of effects and styles. By understanding the basics of HSL and how to use it in CSS, you can take your web design skills to the next level.