<htmlstart/>

CSS Colors

Set colors using names, hex, rgb, hsl, and more.

Color Formats

/* Named color */
color: red;
color: tomato;
color: steelblue;

/* Hex (6-digit) */
color: #D62828;
color: #ffffff;

/* Hex shorthand (3-digit) */
color: #fff;   /* same as #ffffff */
color: #333;   /* same as #333333 */

/* RGB */
color: rgb(214, 40, 40);

/* RGBA — with opacity 0–1 */
color: rgba(214, 40, 40, 0.5);

/* HSL — hue (0-360), saturation %, lightness % */
color: hsl(0, 73%, 50%);

/* HSLA */
color: hsla(0, 73%, 50%, 0.8);

Background Color

body {
  background-color: #F5F3EE;
}
.card {
  background-color: rgba(0, 0, 0, 0.05);
}

CSS Custom Properties (Variables)

:root {
  --primary: #D62828;
  --bg: #F5F3EE;
}

button {
  background: var(--primary);
  color: var(--bg);
}
Use HSL for design systems — easy to adjust lightness/saturation while keeping the same hue.
🧩

Test Yourself

4 questions
Q1.Which CSS color format uses hue, saturation, and lightness?
Q2.What does the "a" in rgba() control?
Q3.What is the 3-digit shorthand for #ffffff?
Q4.Which CSS property sets the text color?