Quackit Logo

HTML Colors

In HTML, colors are specified using hexadecimal values. Hexadecimal values are a combination of letters and numbers, preceeded with a hash (#). For example, #ffff66 is a hexadecimal value. This might look a little intimidating at first, but you will soon get used to it.

You also have an option of using a color name instead of the hexadecimal value. An example of a color name is blue. Only 16 color names are supported by the HTML 4.0 standard. Hexadecimal, on the other hand, provides you with thousands more options. Therefore, if you need to use a color not specified by a color name, you will need to use the hexadecimal value.

In the original specification for HTML, colors were specified using the color attribute (for foreground colors) and bgcolor (for background colors). These attributes have now been deprecated by the W3C (World Wide Web Consortium), so you should avoid using them.

Colors are now specified using the style attribute, in conjunction with the color property or, as we saw in the previous lesson, the background-color property.

Color Names

As mentioned, there are 16 color names. The chart below shows these names and their corresponding hexadecimal value.

ColorColor NameHexadecimal Value  ColorColor NameHexadecimal Value
 Black#000000   Green#008000
 Silver#c0c0c0   Lime#00ff00
 Gray#808080   Olive#808000
 White#ffffff   Yellow#ffff00
 Maroon#800000   Navy#000080
 Red#ff0000   Blue#0000ff
 Purple#800080   Teal#008080
 Fushia#ff00ff   Aqua#00ffff

Example of Color Usage

<h3 style="color:#ff00ff">HTML Colors</h3>

This results in:

HTML Colors

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!