## What is Hexadecimal Code?

Hexadecimal code is a combination of digits and letters, according to the hexadecimal number system. This means that every number place can go from 0 to F, so in total 16 different numbers. When a value of a numbers place exceeds 9, letters are used. As shown in the table below:

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |

## Other Number Systems

Besides the hexadecimal number system there are more number systems used in programming. Like of course the binary number system ,the octal number system and the decimal number system.

If you are new to programming, you should definately read this article about many terms used in programming.

### Binary

The binary number system goes from 0 to 1, which is very suitable to describe an on/off state. This system is central in programming. Every written program can be deduced to binary code.

Not familiar with binary? You should go through this free binary tutorial.

### Octal

Less known is the octal number system, which goes from 0 to 7. It is used in programming, because it’s easy to convert from binary to octal. This also applies to hexadecimal. The difference is that you don’t need additional symbols like letters, but on the other hand you need more space compared to hexadecimal.

### Decimal

We are most familiar with the decimal system. Numbers within the system range from 0 to 9. It’s the standard system used when a numeric value is applied to anything.

## What is the RGB Color System?

RGB simply stands for Red Green Blue. By combining these three colors any other color can be made. For example to get the color yellow, you combine red and green. Combining red and blue results in purple.

The RGB color system starts with black and ends with white. So the color black has the lowest value, while white has the highest value.

## How does an RGB Value Work?

To indicate the amount of each of the three colours in the resulting color, a value is needed for each color. This value can be expressed with any number system.

The total value for each of the three colors can range from 0 to 255, expressed in decimal. In hexadecimal the value ranges from 0 to FF.

So when we take 255 as a value for red, 87 for green and 51 for blue, we get this orange color:

In hexadecimal this corresponds to FF, 57 and 33.

The hexadecimal code for this color would be written as #FF5733. The hashtag is added to indicate that it is a hexadecimal code. As you can see every one of the three colors takes two digits. Red comes at the beginning, followed by green and blue.

The value for black is #000000 while the value for white is #FFFFFF. Every color between black and white can be formed by mixing the tree colors: red, green and blue. To get one of these three colors alone you simply maximize its value, while putting the other two colors at a value of zero.

So to get pure red, you put the two first digits at FF the highest value. The other four digits, two standing for green and two for blue remain at zero. The result is #FF0000. For green the result would be #00FF00, for blue #0000FF.

## Other Color Systems

The RGB color system is one way of defining colors. This means there are many other color systems. Let’s look at some of the most populair. There is the HSL system and the CYMK system.

### HSL

HSL stands for Hue Saturation and Lightness. By selecting a value for these three a color is determined.

Hue represents a color wheel of 360 degrees. So the value for hue actually ranges from 0 to 360. Every degree has its own color. When you select a value for the degree, you select a “main”color.

Saturation is expressed as a percentage and indicates how much of the color gray is mixed with the main color. A percentage of zero indicates the most amount of grey added to the main color.

Lightness indicates the amount of white or black added tot the main color. It’s also expressed as a percentage. A percentage of 0 gives you total black, while a percentage of 100 leads to total white.

### CYMK

CYMK is the standard color system used in printing. The abbreviation stands for Cyan, Yellow, Magenta and Key. Key stands for the color black. These four colors are combined to come up with a new color. This is done by indicating a percentage for each color.

The difference with the RGB system lies in the way light is used. RGB is suitable for light being emitted from a screen. So it starts with black and adds to that. With printing it’s the opposite, it starts with white (a sheet of paper) and the colors are added to white.

## Why is the Hexadecimal Number System Used in Color Coding?

It takes less space to present something in hexadecimal. A binary number of 8 digits (a byte) can be described with just 2 hexadecimal digits. This leads to a nice compact display of data.

Some colors can even be shortened further. Black can be written as #000 instead of #000000. There are many other examples like this.

The conversion between binary and hexadecimal is easier for computers. So using hexadecimal numbers might lead to some performance gains.

Hexadecimal code for RGB color coding has become standard practice (for example in html), so changing to something else would be confusing.