HTML and CSS  Home HTML and CSS Tutorials About Colors in HTML
rss

About Colors in HTML

Author: Jeff Singer More by this author


About Colors in HTMLYou probably see a lot of things in HTML documents that look like random sets of characters and numbers. These items such as #FF0FF0 and #E1A0BB when used with COLOR and BGCOLOR tell the browser what color to display your text or background in.

It is not my point to bore you with hexadecimal math, or even color theory, but just to clue you in enough that you can manipulate your page's color to suit your tastes.

Color on your monitor is created by mixing various amounts of RED, GREEN,& BLUE. At the extremes are WHITE (all colors at maximum brightness) and BLACK (the lack of all colors). HTML can create up to 16,777,216 colors- provided the computer's video card can handle it.

HTML accomplishes this by using the RGB Model. Each color, RED, GREEN, & BLUE can have one of 256 values. (The actual range is 0-255) So if you have three colors- you have 256 X 256 X 256 possibilities. You are probably wondering why we use #FFFFFF instead of #255255255...

Many values with computers are expressed in what is called HEX which is short for hexadecimal. This is referred to as a BASE-16 numbering system. The best way to picture it is to look at a car's odometer. Imagine for a moment that instead of each digit ranging from 0-9 it ranged from 0-15! Get it? Here is how we count...

0 1 2 3 4 5 6 7 8 9 A B C D E F

What happens after F? 10. In this case though, 10 really means 16! So to do our colors we have a set of numbers ranging from 000000 to FFFFFF. If we used our familiar BASE-10 (decimal) system you would have a range of numbers ranging from 00000000 to 16777216. Here is the beauty of the HEX system:

Each two character set controls one color. The first two are for RED, the second two are for GREEN, and the last two are for blue. The higher any set is (from 00-FF) the more of that color is shown.

Here are some simple examples:

  • #FF0000 RED
  • #00FF00 GREEN
  • #0000FF BLUE
  • #FFFF00 YELLOW
  • #000000 BLACK


Rate this Material: Bad 1 2 3 4 5 Excellent
print this page tell a friend subscribe to newsletter subscribe to rss

Add comments to "About Colors in HTML"