HTML - Color codes

  »   HTML  »   HTML Tutorial - Hexadecimal, RGB color codes, inserting colors into html pages / safe colors

There are three different ways of defining color. The easiest way is to name the color in English. For example: black, white, red, green and blue. I have put together the names of the color which are supported in HTML

ColorHexaColorHexColorHexColorHex
aqua#00FFFFgreen#008000navy#000080silver#C0C0C0
black#000000gray#808080olive#808000teal#008080
blue#0000FFlime#00FF00purple#800080white#FFFFFF
fuchsia#FF00FFmaroon#800000red#FF0000yellow#FFFF00

HTML - The RGB color system

This color code is not recommended because Internet Explorer is the only browser that 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 the way of how you write RGB colors. If you use a browser that is not Internet Explorer you will have no result.

bgcolor="rgb(255,255,255)"White
bgcolor="rgb(255,0,0)"Red
bgcolor="rgb(0,255,0)"Green
bgcolor="rgb(0,0,255)"Blue

HTML - The hexadecimal color system

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

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

htmlbgcolor="#FFFFFF"

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.

Decimal

0123456789101112131415

HEX

0123456789ABCDEF

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

An example of hexadecimal code would be:

htmlbgcolor="#FFFFFF"

The "F" letter is the maximum value that 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 we multiply it by 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

*000300600900C00*F00
*003303603903C03*F03
006306606906C06F06
009309609909C09F09
00C30C60C90CC0CF0C
*00F30F60F90FC0F*F0F
030330630930C30F30
033333633933C33F33
036336636936C36F36
039339639939C39F39
03C33C63C93CC3CF3C
03F33F63F93FC3FF3F
060360660960C60F60
063363663963C63F63
066366666966C66F66
069369669969C69F69
06C36C66C96CC6CF6C
06F36F66F96FC6FF6F
090390690990C90F90
093393693993C93F93
096396696996C96F96
099399699999C99F99
09C39C69C99CC9CF9C
09F39F69F99FC9FF9F
0C03C06C09C0CC0FC0
0C33C36C39C3CC3FC3
0C63C66C69C6CC6FC6
0C93C96C99C9CC9FC9
0CC3CC6CC9CCCCCFCC
0CF3CF6CF9CFCCFFCF
*0F03F0*6F09F0CF0*FF0
0F3*3F3*6F39F3CF3*FF3
*0F6*3F66F69F6*CF6*FF6
0F93F96F99F9CF9FF9
*0FC*3FC6FC9FCCFCFFC
*0FF*3FF*6FF9FFCFF*FFF

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:

*000*F00
*003*F03
*00F*F0F
*FF0*FF3
*CF6*FF6
*0F0*6F0
*3F3*6F3
*0F6*3F6
*0FC*3FC
*0FF*3FF
*6FF*FFF