HTML HSL Colors
In this page:
<tagname style="color: hsl(hue, saturation%, lightness%);">content</tagname>
The Hue Wheel
Hue is a value from 0 to 360 representing a position on the color wheel: 0 is red, 120 is green, 240 is blue, and 360 loops back around to red again. Hue alone determines which color you are looking at, independent of how vivid or light it appears.
Example: The Hue Wheel
<p style="color: hsl(0, 100%, 50%);">Hue 0 = red</p>
<p style="color: hsl(240, 100%, 50%);">Hue 240 = blue</p>
Controlling Vividness with Saturation
Saturation is a percentage from 0% to 100% controlling how vivid or muted a color appears -- 100% saturation gives a pure, intense hue, while 0% saturation removes all color entirely, leaving only a shade of gray regardless of the hue value.
Example: Controlling Vividness with Saturation
<p style="color: hsl(200, 100%, 50%);">Fully saturated</p>
<p style="color: hsl(200, 0%, 50%);">Zero saturation = gray</p>
Controlling Tone with Lightness
Lightness is a percentage from 0% to 100% controlling how close a color sits to black or white -- 0% is always pure black, 100% is always pure white, and 50% shows the hue at its purest, most saturated-looking form.
Example: Controlling Tone with Lightness
<p style="color: hsl(200, 100%, 0%);">0% lightness = black</p>
<p style="color: hsl(200, 100%, 50%);">50% lightness = pure hue</p>
<p style="color: hsl(200, 100%, 100%);">100% lightness = white</p>
Building Tints and Shades
Because HSL separates the "which color" question (hue) from the "how light" question (lightness), it is the easiest notation for generating a coordinated palette -- keep hue and saturation locked, then vary only lightness to produce a smooth ramp of shades for hover states, borders, and backgrounds that all clearly belong to the same color family.
Example: Building Tints and Shades
<div style="background-color: hsl(210, 80%, 40%);">Dark</div>
<div style="background-color: hsl(210, 80%, 60%);">Medium</div>
<div style="background-color: hsl(210, 80%, 80%);">Light</div>
Adding Transparency with hsla()
hsla(hue, saturation, lightness, alpha) adds the same fourth alpha value used in rgba(), ranging from 0 (fully transparent) to 1 (fully opaque), letting an HSL color blend with the content behind it.
Example: Adding Transparency with hsla()
<div style="background-color: hsla(210, 80%, 50%, 0.5);">Semi-transparent overlay</div>
- Confusing saturation and lightness, when saturation controls color intensity/vividness while lightness controls how close the color sits to black or white.
- Forgetting that hue is measured in degrees around a 360-degree color wheel, so 0 and 360 both point to red.
- Setting lightness to 0% or 100% and expecting to still see the hue, when those extremes always produce pure black or pure white regardless of hue or saturation.
- HSL describes color as Hue (0-360 degrees), Saturation (0-100%), and Lightness (0-100%).
- Keeping hue and saturation fixed while only changing lightness is the easiest way to generate a consistent set of tints and shades of one color.
- hsla() adds the same alpha transparency channel found in rgba(), as a fourth value from 0 to 1.
hsl() and hsla() color notation is supported in all modern browsers, including Chrome, Firefox, Safari, and Edge.
Chapter Quiz — Complete all 26 topics to unlock
0/26 topics done
Complete these topics first:
- HTML Favicon
- HTML Page Title
- HTML Tables
- HTML Lists
- HTML Block & Inline
- HTML Comments
- HTML Colors
- HTML CSS
- HTML Links
- HTML Images
- HTML RGB Colors
- HTML HEX Colors
- HTML HSL Colors
- HTML Link Colors
- HTML Link Bookmarks
- HTML Background Images
- HTML Table Borders
- HTML Table Sizes
- HTML Table Headers
- HTML Table Padding & Spacing
- HTML Colspan & Rowspan
- HTML Table Styling
- HTML Table Colgroup
- HTML Unordered Lists
- HTML Ordered Lists
- HTML Other Lists / Description Lists