CSS colors

W3C CSS Snapshot 2026

Write the same teal using three different CSS color notations.

On this page

Hex colors

A six-digit hex color starts with #. Read the next six characters in pairs as red, green, and blue. Each pair ranges from 00 to ff.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Hex colors</title>
  <style>
.card { color: #008080; }
  </style>
</head>
<body>
<p class="card">Desk Lamp</p>
</body>
</html>

What to expect The text is teal. Change the first pair to ff and compare.

RGB channels and opacity

rgb() accepts red, green, and blue. With numbers, each channel ranges from 0 to 255. Add / and an alpha value to set how much of the background color shows through.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>RGB channels and opacity</title>
  <style>
.card { color: rgb(0 128 128); background: rgb(0 128 128 / 20%); padding: 8px; }
  </style>
</head>
<body>
<p class="card">Desk Lamp</p>
</body>
</html>

What to expect Teal text appears over a faint teal background. Change 20% to 10%.

Hue, saturation, and lightness

Hue is an angle on the color wheel. Saturation controls how vivid the color is. Lightness ranges from black at 0% to white at 100%.

How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Hue, saturation, and lightness</title>
  <style>
.card { color: hsl(180deg 100% 25%); }
  </style>
</head>
<body>
<p class="card">Desk Lamp</p>
</body>
</html>

What to expect The text is teal. Change the hue to 300deg to see purple.

Official references