Colors
4.2
Lesson

RGB Color Values

With color names, you can only choose from the 140 ones given here: color names. For styling, we need more freedom.

To get a specific colour, we can mix the 3 primary colours Red, Green and Blue in different proportions. This way, we can create any colour that we require.

For example, look at the code given below:

The h1 has a text color of Orange because we mixed red with an intensity of 255, green with an intensity of 165 and blue with an intensity of 0.

The p element with id one has text color gray because in the rgb code, we have all three colors with an intensity of 128.

Each parameter takes a value ranging from 0 to 255, 0 being least intensity and 255 being highest intensity.