Hex Color

A hex color is a way of specifying a color in CSS using a hash followed by six hexadecimal digits, like #ff0000 for red. The digits encode the red, green, and blue components.

Web

Each pair of digits (00 to ff) sets the intensity of red, green, and blue. #000000 is black, #ffffff is white, and everything else mixes the three channels.

Shorthand three-digit hex codes like #f00 expand each digit (so #f00 equals #ff0000). An optional fourth pair adds transparency (alpha).

Examples

CSS

body {
  background: #1a1a2e;
  color: #e0e0e0;
}

Output:

Renders a dark navy background with light gray text.

Learn it in a lesson

See also

Back to the Dictionary