Usage of hsla() CSS function


To define colors using the Hue-Saturation-Lightness model (HSL), use the hsla() CSS method.

You can try to run the following code to implement the hsla() function in CSS

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         h1 {
            background-color:hsl(0,100%,50%);
         }
         h2 {
            background-color:hsl(192,89%,48%);
         }
         p {
            background-color:hsla(290,100%,50%,0.3);
         }
      </style>
   </head>
   <body>
      <h1>Red Background</h1>
      <h2>Blue Background</h2>
      <p>This is demo text!</p>
   </body>
</html>

Updated on: 25-Jun-2020

128 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements