Html color codes

In HTML, you can specify the colors for the text and background of a Web page to make it more attractive and appealing.

HTML defines 16 widely known colors that you can apply to a Web page by specifying the name of the color as the value of the text attribute of the BODY element.

Alternately, you can use the hexadecimal (Hex) values of colors, which imply that the value of the text attribute must be the hexadecimal value of the color. You can also apply colors to a Web page by using the RGB color mode. In this case, the text attribute contains the RGB value of the color.

You can apply colors in a Web page with the help of

  • Color names
  • Hex values
  • RGB configuration
  • Web-safe colors

HTML Color Names

You can use a color in a Web page by simply specifying its name. However, there are only 16 colors that can be specified by their names. For example, you need to design a Web page, in which you want to display the text in red color. You can do so by using the text attribute of the BODY element. You can specify a color by typing the name of the color as the value of the text attribute in the BODY element.

HTML Color Hex Values

The Hex values, also referred as hexadecimal numbers, are 6 digits or three bytes number that start with the # sign. The three bytes present in every hexadecimal number represent the following :

  • Byte 1 — Represents the red color
  • Byte 2 — Represents the green color
  • Byte 3 — Represents the blue color

Each byte contains some numbers from 00 to 99 and alphabets from AA to FF in hexadecimal notation.

The Hex values are defined through the combination of values assigned to red, green, and blue colors. When you use a Hex value to apply a color in an image, you can use numerals as well as alphabets. In Hex value, 0 represents the darkest color that is black and F represents the lightest color that is white. For example, the hexadecimal number for black is #000000. The first two digits (00) represent the amount of red color. The second two digits (00) represent the amount of green color, and the last two digits (00) represent the amount of blue color.

HTML Color RGB Values

The process of displaying colors by using the different combinations of red, green, and blue is known as the RGB configuration.

It is a set of three dials, where the first dial represents red, second dial represents green, and the third dial represents the blue color.

In the RGB configuration, the value of each color (red, green, and blue) ranges from 0 to 255 in decimal. The color specified by 255, 0, 0 represents the red color because its first dial contains the value 255 that represents the red color, while the second dial representing the green color and the third dial representing the blue colors contains 0 (means no color).

In the same way, the color specified by 0, 255, 0 represents the green color, and the color specified by 0, 0, 255 represents the blue color. If all the three dials are turned off, such as 0, 0, 0 then this is the condition of the absence of color or simply black color. On the other hand, if all the dials are turned on, such as 255, 255, 255 then it represents the white color.

HTML Color Names and their RGB Values

The following table provides information about the names of color and their RGB values.

HTML Web-safe Colors

Earlier, a computer system is used to support only 256 colors, out of which 216 colors are Web standard colors displayed correctly by all computer systems. These colors are known as Web-safe colors that are only defined by using the values, 00, 33, 66, 99, AA, CC, or FF. A Web-safe color can use any combination of these values. For example, #99FF00 is a Web-safe color but #221144 is not a Web-safe color. The 00 represents the darkest value for each color and the FF represents the brightest value for each color.

HTML Color Values

Colors are displayed combining RED, GREEN, and BLUE light

HTML Colors with their names and HEX values

Look at the following table which lists the HTML Colors with their names and HEX Values:

HTML Online Test

« Previous Tutorial Next Tutorial »

HTML — The RGB color system

This color code is not recommended because Internet Explorer is the only browser which supports RGB values in HTML.

RGB is a shortcut from : Red, Green, Blue. Every single color of these can take any value between 0 (which doesn’t matter) and 255 (the full proprieties of that color).I have put together in the way of how you write RGB colors. If you use a browser which is not Internet Explorer you will have no result.

HTML — The hexadecimal color system

The hexadecimal system is pretty hard at first look but with all this we assure you that once with the time passing, and with a bit of practice, you will understand it fully. The hexadecimal color system is the standard system for all the web browsers. Is confident and compatible not only in web applications.

The hexadecimal system is a representation of 6 color characters. First two characters (RR) represents the red value, and the next two (GG) are green, and the last two (BB) are blue.


HTML — Color code — Breaking the code

The next table shows , more precisely, how the letters are integrated in the hexadecimal system, making the combination possibilities bigger.


In this way the possibilities are bigger and the system can have 16 values.

An example of hexadecimal code would be:


The «F» letter is the maximum value whom the system can take. When a browser sees this code it will show the white color.In case you want to find out the numerical value of this color we have the next formula:

html(15 * 16) + (15) = 255

The formula is very simple. We take the first value of the «F» or 15 and is multiplied with 16 and we add to the second value 15. The result is 255, the maximum value whom a primary color can have.

htmlbgcolor="#CC7005"  CC(RR - Red) (12 * 16) + (12) = 204  70(GG - Green) (7 * 16) + (0) = 112  05(BB - Blue) (0 * 16) + (5) = 5

True colors

The hexadecimal system is very used for creating pages. This is compatible with the majority of the browsers, in this way the displayed colors for a web page will not be changed. As an assurance, use the colors true colors like :»#0011EE», «#44HHFF», or «#117788». This type of colors will not be changed in a browser.

Here we have a list of the true colors

We recommend to stick to these 216 «web-safe». However, 8-bit color displays were much more common when the 216-color palette was developed than they are now. Anyway, it has been discovered that only 22 of the 216 colors in the web-safe palette are reliably displayed without inconsistent remapping on 16-bit computer displays.

We attached here a table with these 22 really safe colors:

You May Also Like

About the Author: admind

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.