How many colours are there?
There are 140 named colours in CSS. This includes colours like:
- Tomato
- Orange
- DodgerBlue
- MediumSeaGreen
- Gray
- SlateBlue
- Violet
- LightGray
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:
- Red slider (0 to 255)
- Green slider (0 to 255)
- Blue slider (0 to 255)
For example:
rgb(255, 0, 0)= bright redrgb(0, 255, 0)= bright greenrgb(0, 0, 255)= bright blue
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.
- ff = maximum
- 00 = none
So:
#000000= black (no light)#ff0000= red#00ff00= green#0000ff= blue
Mixing colours
By mixing different levels of light, you can get almost any colour you can imagine:
#ffff00= yellow#00ffff= cyan (light blue)#ff00ff= magenta (pink)#ffffff= white#8f213a= custom colour (wine)#7c8cca= custom colour (blue-purple)
Try it yourself
Use this online colour mixer to mix colours and get their hex codes:
Online colour mixer