Understanding: Hex Colors

Learn how colors are represented in HTML and CSS using the hex color format and the RGB color model.

What is a Hex Color?

The Basics

A hex color is a way to represent colors using hexadecimal (base-16) numbers. In HTML and CSS, colors are written as a # symbol followed by six characters.

#RRGGBB

Each pair of characters represents a color channel: Red, Green, and Blue. By mixing these three primary colors of light, we can create any color on screen.

RGB Channels

Mixing Light Colors

Each channel has a value from 0 to 255 in decimal, or 00 to FF in hexadecimal. This gives us 256 possible values per channel.

256

Red values

256

Green values

256

Blue values

Combined: 256 x 256 x 256 = 16,777,216 possible colors!

DecimalHexMeaning
000No intensity (minimum)
12880Half intensity
255FFFull intensity (maximum)

Reading Hex Codes

Examples

Red

#FF0000

rgb(255, 0, 0)

Green

#00FF00

rgb(0, 255, 0)

Blue

#0000FF

rgb(0, 0, 255)

Yellow

#FFFF00

rgb(255, 255, 0)

Cyan

#00FFFF

rgb(0, 255, 255)

Magenta

#FF00FF

rgb(255, 0, 255)

White

#FFFFFF

rgb(255, 255, 255)

Black

#000000

rgb(0, 0, 0)

Try It Yourself

Interactive Demo

Interactive Color Mixer

128(80)
128(80)
128(80)

Quick presets:

#808080

rgb(128, 128, 128)

Hex Mixer Game

Practice Color Mixing

Hex Mixer is a daily color puzzle game where you mix colors to match a target. Each day brings a new challenge generated from a seed based on the date.

How It Works
Color Mixing Formula

When you add a color drop to the mix, the result is calculated using weighted averaging:

NewColor = (OldColor * (Drops - 1) + NewDrop) / Drops
Accuracy Calculation

Your score is based on how close you get to the target color:

sumDiff = |R_diff| + |G_diff| + |B_diff|
accuracy = 100 - (sumDiff / 765 * 100)

765 = 255 x 3, the maximum possible difference across all channels.

Daily Puzzle Generation

Each puzzle is generated using a seeded random algorithm based on the current date (YYYYMMDD). This means everyone worldwide sees the same puzzle each day!

Color Reference

Common Colors

ColorHexRGBPreview
Red#FF0000255, 0, 0
Green#00FF000, 255, 0
Blue#0000FF0, 0, 255
Yellow#FFFF00255, 255, 0
Cyan#00FFFF0, 255, 255
Magenta#FF00FF255, 0, 255
White#FFFFFF255, 255, 255
Black#0000000, 0, 0
Back to HomePlay Hex Mixer