Select Page

Color in HTML

Color adds a lot of information to your documents. It is rare to see a webpage with only black text on white background. Luckily you have 16.7 million colors in HTML to spice up your pages. You can specify these colors in two ways. You can either use one of the 16 named colors (see below), or you can specify the color using its hexadecimal code.
The hexadecimal codes have the format “#RRGGBB”, which define exactly how much of the primary colors red, green and blue you want. An example is #990099, which mixes a bit of red and blue to define a purple’ish color.

Standard HTML colors

The HTML 4.01 specification defines 16 named colors. Although many browsers understand a lot more names, these are the only ones actually in the standard, so any other color-names should be used with caution.

  Black #000000
  Gray #808080
  Silver #C0C0C0
  White #FFFFFF
  Maroon #800000
  Red #FF0000
  Fuchsia #FF00FF
  Green #008000
  Lime #00FF00
  Olive #808000
  Yellow #FFFF00
  Navy #000080
  Blue #0000FF
  Teal #008080
  Aqua #00FFFF

HTML color chart

The complete table of the 216 web-safe colors is presented below. Hover your mouse over each color to see the rgb-value, and use it to gain a feel for how the different mixes of rgb colors make different colors (it has never been very intuitive for me that a mix of red and green makes yellow for example).

‘ . PHP_EOL;
for($b=0;$b<6;$b++) { $color = $steps[$r] . $steps[$b] . $steps[$g]; echo '

‘ . PHP_EOL;
echo ‘

‘ . PHP_EOL;


The origin of the web-safe colors is years ago when we didn’t have as many colors in our displays as we do today. Back then we were limited to using only 216 colors. In these colors the values of red, green and blue could only be either 00, 33, 66, 99, CC or FF. Today most browsers display 24-bit graphics, so it is not so much of a problem anymore.