Favorites

hsla() CSS Function

hsla()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The hsla() function defines a color by hue, saturation, lightness and alpha. It is a legacy alias of hsl(), which now accepts alpha too.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The hsla() CSS function is used to define colors using the Hue, Saturation, Lightness, and Alpha model, offering a more intuitive approach to color specification compared to the traditional rgb() function. The first parameter, hue, represents the color’s position on the color wheel in degrees (0–360), where 0 or 360 is red, 120 is green, and 240 is blue. The second parameter, saturation, determines the intensity of the color as a percentage; 0% produces a shade of gray, while 100% gives the full color. The third parameter, lightness, also expressed as a percentage, controls how light or dark the color appears: 0% is completely black, 50% is the pure color, and 100% is completely white. The fourth parameter, alpha, specifies the transparency level of the color, ranging from 0 (fully transparent) to 1 (fully opaque).

Using hsla() allows for dynamic color adjustments, such as creating hover effects, overlays, or gradients with varying transparency. It pairs seamlessly with CSS properties like background-color or color, enabling developers to apply semi-transparent colors without affecting underlying elements.

Example:

div {
  background-color: hsla(200, 70%, 50%, 0.5);
  color: hsla(0, 0%, 100%, 1);
}

In this example, the div will have a semi-transparent blue background and fully opaque white text. This makes it especially useful when layering elements or creating subtle visual effects on div containers.

Interactive Demo

Colour swatch
Demo Code
HTML Code
<div class="demo-checker">
	<div class="demo-element">Colour swatch</div>
</div>
CSS Code
.demo-checker {
	width: 296px;
	padding: 18px;
	box-sizing: border-box;
	background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 20px 20px;
}
.demo-element {
	width: 260px;
	padding: 18px;
	border-radius: 8px;
	font-size: 16px;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 1px 2px rgb(0 0 0 / 40%);
	background-color: hsla(330, 93%, 56%, 1);
}

Syntax

hsla() = hsla( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )

/* legacy comma-separated syntax */
hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )

/* hsla() is an alias of hsl() */

Values

  • huerepresents an angle of the color circle. You can specify the value as an angle in degrees (e.g. 180deg) or simply as a number (e.g. 180). For example, blue is at 240 degrees, so it could be written as either 240deg or 240. By definition, red=0°=360°, with the other colors spread around the circle, so green=120°, blue=240°, etc.
  • saturationsaturation is expressed as a percentage. It represents the amount of saturation in the color. For example, 100% is fully saturated (more colorful and intense), while 0 is a fully-unsaturated gray.
  • lightnesslightness is also expressed as a percentage. It represents the amount of light in the color. For lightness, 50% is the "normal" setting, while 100% is white and 0% is black.
  • alphadetermines how transparent the color is. A value of 1 is fully opaque, while a value of 0 is fully transparent. A value of 0.5 is semi-transparent.

Example

<div class="container">
<div class="box solid">Solid Green</div>
<div class="box transparent">Transparent Green</div>
<div class="box light">Light Mint Green</div>
</div>
.container {
display: flex;
gap: 20px;
padding: 20px;
font-family: sans-serif;
}

.box {
width: 150px;
height: 150px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
border: 2px solid #333;
}

/* hsla(hue, saturation, lightness, alpha) */

.solid {
/* Full green, 50% lightness, 1.0 opacity */
background-color: hsla(145, 70%, 50%, 1);
}

.transparent {
/* Same green, but 0.3 opacity (see-through) */
background-color: hsla(145, 70%, 50%, 0.3);
}

.light {
/* Same green, but 90% lightness (pastel/mint) */
background-color: hsla(145, 70%, 90%, 1);
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS hsla() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.