Hex code for colors: Everything about hexadecimal color definition

Hex code for colors: Everything about hexadecimal color definition

In the digital world, colors are often defined using what is known as a hex code. This means that over 16 million different colors and shades can be displayed. In this guide you will find out how exactly the hexadecimal color definition works and how you can find out the hex code of a certain color.

Short digression: the hexadecimal system

In order to understand exactly how hex codes for colors work, let's first take a little excursion into the hexadecimal system, because the word "hex" in hex code stands for hexadecimal number.

In everyday life we almost exclusively use the decimal system for arithmetic. This consists of ten digits (0 to 9). If a number reaches a value higher than nine, a new digit is "opened" in order to be able to represent the number, for example the number 13. It is therefore a number system with a base of 10.

In the hexadecimal system, on the other hand, numbers are represented in a place value system based on base 16. It consists of 16 hexadecimal digits. There is something special here. Since our Indo-Arabic number system only knows ten digits, the missing six hexadecimal digits above nine cannot be represented with a number. That is why the letters A to F are used for this. The hexadecimal number A is converted into the decimal system, i.e. 10, B is 11 and F is 15.

The hexadecimal system is preferred for use in electronic data processing. As a fourth power of two (2 ^ 4 = 16), the hexadecimal system is well suited for convenient management of the binary system.

How does hex code work for colors?

Now that you know how the hexadecimal system works, we can now look at how hexadecimal numbers are used in color definition. The hex code for colors consists of six digits, usually preceded by a hash (#). Two digits each indicate the mixing ratios of the colors red, green and blue (RGB) in the hex code. A hex code for a color has the following scheme: # RR GG BB .

One of 16 hexadecimal digits can appear at any point in the code. Since the three colors are each defined over two places, there are 256 states (16 x 16 digits) per color. If we now combine every possible mixing ratio of the three colors, we get 16,777,216 colors (256 x 256 x 256). This is also referred to as a color depth of 24 bits (2 ^ 24 = 16,777,216).

Examples of colors in hex code format

In the following table you will find some basic and mixed colors and their associated hex code. You will also find the color coding in the decimal system in RGB format.

colour Hex value RGB decimal
black # 000000 0 | 0 | 0
White #FFFFFF 255 | 255 | 255
Gray # 888888 136 | 136 | 136
Red # FF0000 255 | 0 | 0
green # 00FF00 0 | 255 | 0
blue # 0000FF 0 | 0 | 255
Cyan # 00FFFF 0 | 255 | 255
magenta # FF00FF 255 | 0 | 255
yellow # FFFF00 255 | 255 | 0
Blue green # 00FF88 0 | 255 | 136
Sky blue # 0088FF 0 | 136 | 255
violet # 8800FF 136 | 0 | 255
Rose # FF0088 255 | 0 | 136
orange # FF8800 255 | 136 | 0
Yellow-green # 88FF00 136 | 255 | 0

This is how you determine the hex code for a specific color


The hex code for the background color for the lettering "from SATURN" is, for example, 25A8D4. Image:

If you want to use a certain color, for example when programming in HTML or in image processing software, it is very helpful to know its hex code. If you have a picture on which the desired color can be seen, you can use the Image-Color website to find out the exact hex code for the color and then use it yourself.

To do this, you must first upload the image to the site. Then click on the desired color in the uploaded image with the cursor and the website will tell you the corresponding hex code.


  • Hex code for colors consists of six digits preceded by a diamond. Two digits each define the color components of red, green and blue (RGB).
  • The six digits in the hex code are not decimal but hexadecimal numbers. These are represented with the digits from 0 to 9 and the letters A to F for the numbers from 10 to 15.
  • A total of 16,777,216 colors can be displayed using the six-digit hex code. One speaks here of a color depth of 24 bit.
  • If you want to find out the hex code of a certain color on an image, you can upload the image to the Image-Color website and have the respective code displayed there.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.