Rashielea Coding Club

Lesson 4.5: 🎨 Hex codes

How many colours are there?

There are 140 named colours in CSS. This includes colours like:

What if I don't like those colours?

You're in luck! if you need a colour which isn't named explicitly, you can create a colour manually using its hex code.

The hex code is a combination of how much of each colour to mix together to get the exact shade you want.

Using hex codes, you can make over 16 million different colours.

Mixing primary colours

To make any colour you want, you can mix red, green, and blue light.

Think of it like 3 sliders:

For example:

Hex colours (the secret code version)

Computers sometimes write colours in a shorter “code” called a hex code.

It looks like this:

#ff0000 = red

A hex colour is split into 3 parts: red, green, and blue.

Each pair of characters controls how much red, green, and blue light you get.

So:

Mixing colours

By mixing different levels of light, you can get almost any colour you can imagine:

Try it yourself

Use this online colour mixer to mix colours and get their hex codes:

Online colour mixer
Back to lesson 4