CSS: HSL Color
HSL Color Generator
Code:
Hue:
Saturation:
Lightness:
HSL Color Syntax
Syntax using space separator and slash
Syntax using space separator was introduced around 2020.
hsl(hue saturation lightness)
hsl(hue saturation lightness / opacity)
- hue
- a integer from 0 to 360.
- saturation
- percentage. (the % can be omitted)
- lightness
- percentage. (the % can be omitted)
- opacity
- a number from 0 to 1.
/* gold */ /* Hex: #FFD700 */ /* space as separator */ p { background-color: hsl(51 100 50); } /* percentage */ p { background-color: hsl(51 100% 50%); } /* with opacity */ p { background-color: hsl(51 100% 50% / 50%); } /* with opacity as number */ p { background-color: hsl(51 100% 50% / 0.5); }
Syntax using comma separator (legacy)
comma separator syntax is older, available since 2012 at least.
hsl(hue, saturation, lightness)
hsl(hue, saturation, lightness, opacity)
/* comma as separator */ p { background-color: hsl(51, 100%, 50%); } p { background-color: hsl(51, 100%, 50%, 0.5); } p { background-color: hsl(51, 100%, 50%, 50%); }
HSL color samples
HSLA function (legacy)
hsla(hue, saturation, lightness, opacity)
- opacity is from 0 to 1.
div { background-color: hsla(120, 100%, 50%, 0.3); }
CSS Color
- CSS: color syntax. Index
- CSS: Color Names
- CSS: RGB Color
- CSS: rgb()
- CSS: HSL Color
- CSS: HWB color (hue whiteness blackness)
- CSS: what is Wide Color Gamut, Display P3, sRGB.
- CSS: LAB, LCH color
- CSS: OKLCH color
- CSS: color() function
- CSS: color-mix() function
- CSS: Opacity (Transparency)
- JS: Convert Color Names to RGB, and to HSL