HSL Color value Properties

  • HSL representation defines colors based on Hue, Saturation, and Lightness components, offering a more intuitive way to specify colors.
  • Hue represents the color type, ranging from 0 to 360 degrees.
  • Saturation determines the intensity or purity of the color, from 0% (grayscale) to 100% (full color).
  • Lightness controls the brightness of the color, ranging from 0% (black) to 100% (white), with 50% representing normal.

HSL Color value Syntax

// Golden Background
<div style="background-color: hsl(45, 100%, 50%);">
This div has a golden background using HSL
</div>

HSL color value Example:

The example shows the HSL color values.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>HSL Color Value</title>
    <style>
        center {
            width: 50%;
            margin: 0 auto;
        }
        h2, div, p, span {
            padding: 10px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <center>
        <h2 style="background-color: hsla(120, 100%, 50%, 0.5);">
            Heading with semi-transparent 
            Green Background color 
            (HSL: hsla(120, 100%, 50%, 0.5))
        </h2>

        <div style="border: 2px solid hsla(240, 100%, 50%, 0.7);">
            Div with semi-transparent 
            Blue Border color 
            (HSL: hsla(240, 100%, 50%, 0.7))
        </div>
        <span>
            <a href="#" style="color: hsla(30, 100%, 50%, 0.8);">
                Link has a semi-transparent 
                Orange color 
                (HSL: hsla(30, 100%, 50%, 0.8))
            </a>
        </span>
    
        <p style="color: hsla(0, 100%, 25%, 0.6);">
            Paragraph with semi-transparent 
            Red Text color 
            (HSL: hsla(0, 100%, 25%, 0.6))
        </p>
    </center>

</body>

</html>

Output:

hsl color value

HSL Color value Explanation:

  • In this example HSLA(120, 100%, 50%, 0.5) creates a semi-transparent green background for the heading with 50% opacity.
  • HSLA(240, 100%, 50%, 0.7) sets a semi-transparent blue border for the div with 70% opacity.
  • HSLA(30, 100%, 50%, 0.8) defines a semi-transparent orange color for the link with 80% opacity.
  • HSLA(270, 100%, 25%, 0.6) specifies semi-transparent purple text for the paragraph with 60% opacity.


HTML Colors

HTML Colors can be applied to text, backgrounds, borders, links, forms, tables, etc. This article provides an in-depth look at how colors can be applied to various elements such as text, backgrounds, borders, links, forms, and tables in HTML. We will explore different color formats including hexadecimal, RGB, RGBA, HSL, and named colors, offering you precise control over the color presentation on your web pages.

Similar Reads

HTML Colors Name

HTML color names offer a user-friendly way to specify colors. From classic colors like Red, Green, Blue, Pink, Purple, Sky Blue, Gray, and Orange, to more exotic shades, HTML provides a wide palette for web designers. Whether you’re designing a serene theme or a vibrant layout, HTML color names have got you covered....

HTML Color Usage

Green...

Color Values

Blue...

RGB Color Value

Pink...

RGB Color Value Properties

Purple...

RGBA Color Value

Sky Blue...

RGBA Color values Properties

Gray...

HSL (Hue, Saturation, Lightness) Value

Orange...

HSL Color value Properties:

...

HTML Colors Use Cases:

Usage Descriptions Syntax Background ColorHTML Background Color is the shade that appears behind the content on a webpage. The background covers the total size of the element with padding and border but excludes the margin. It makes the text so easy to read for the user. 

Div with magenta background
Text ColorText color in HTML specifies the color of the text content, similar to font color.

Pink color is used

Border ColorHTML Border Color refers to the color of borders around elements like