The Key to Adding Color to

Your Web Page


Background and Text Color Coding

With some slight modifications to the <body> tag , a solid color background can be added to your web page. (No more of that deary, drab gray.)

In a web browser, there are 256 system colors for coloring text and backgrounds. Each color is identified by its Red- Green- Blue (RGB) values, by three numbers that range from 0 to 255, each of which represents the intensity of the Red, Green, or Blue of the desired color. The maximum values of all three (R=255, G=255, B=255) produce the color white and the minimal values (R=0, G=0, B=0) produce black. All other colors are represented by varying RGB triplets.

The Mathematics of Color Values

It gets tricky here. Here is where our math folk might shine. Rather than identifying a color as something like "102,153,255" each number is converted from (normal everyday numbers, digits from 0,1,2,3,4,5,6,7,8,9) base 10 representation to hexadecimal, base 16 (digits from 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). You of course ask, "Why?" Well, the hexadecimal system is more easily and more efficiently understood by computers. So for the color example above, we would write in hexadecimal as "6699FF". In this example, "66" is the Red value, "99" the Green, and "FF" the Blue.

Here are a few hexadecimal codes for different colors:

Color

Hex Code

pink

FFCCCC

lavender

3300FF

bright green

33FF66

red

AA0000

cream (cream)

FFFBF0

light gray

EEEEEE

light blue

A6CAF0

white

FFFFFF

blue

0000FF

dark gray

444444

navy

000077

black

000000

yellow

FFFF00

purple

9900FF

There are also 16 colors which are recognized by browsers by names. This keeps you from having to use the Hex codes. The following are the colors that browswers recognize by name:

  1. aqua
  2. blue
  3. gray
  4. lime
  5. purple
  6. white
  7. silver
  8. navy
  9. yellow
  10. red
  11. marroon
  12. green
  13. fuchsia
  14. black
  15. teal
  16. olive

 


Solid Color Backgrounds

For these Web page lesson pages, the color that we chose was white. Prior to adding the background color tag to the HTML for the pages, the background of the pages was the default, gray. The HTML format for adding a solid color background involves modifying the <body> tag to read:

<body bgcolor=#XXXXXX>

where XXXXXX is the hexadecimal representation (indicated by the # sign in front of it) of the desired color.

 

NOTE:When you use the hexdecimal color code, don't forget that your HTML coding must have the # symbol in front of the six numbers and or letters.


On Your Own
  1. Open one of your HMTL files in your text editor.
  2. Find the <body> tag and change it to:
        <body bgcolor=#FFFFFF>
  3. Save and Load your HTML file in your web browser

If you did things correctly, your browser should have changed the background to a solid white. There are alsosome other options to add to the body tag to color the text in your Web page and to change the color of any of the the hypertext items:

<BODY BGCOLOR=#XXXXXX TEXT=#XXXXXX LINK=#XXXXXX VLINK=#XXXXXX>

where the XXXXXX values will determine:

You can add some of the other color values by changing the tag to read:

  <BODY BGCOLOR=#FFFFFF TEXT=#FFFFCC LINK=#33CCFF VLINK=#CC3333>

 

NOTE: The order of the items in the <BODY> tag does not make any difference, but when you include color values within the body tag, this affects your entire Web page document.


Font Color

Now, change the <BODY> tags in all of the HTML files that you have created. This can be fast and easy to do if you copy and paste the above example and replace the old body tag in your documents with the new <body> tag. Then, change the solid color backgrounds of your web pages to different colors by varying the hex coding. Also, change the color and size of some of your text, to see how this effects the look of your Web page. If you would like to try out background texture files, check out this list of links from Yahoo.

  1. Open up one of your html files in your text editor.
  2. Type in some more text within the body and then edit around some of the text as shown below:

    Be sure to save the changes that you have made and view it in your web browser.
  3. Practice using the <p> and <br> tags for paragraph and line breaks.

    NOTE: Many browsers have the ability to change the default text and background colors. Sometimes a user may have their preferences set for their own choice of colors. The following are the default or "standard" ones that most people use on their Web pages.

    BODY TEXT=#000000 VLINK=#660099 LINK=#0000FF


Lesson 5

Lesson Index


Alice Drive Middle School

Staff Information Index

This is a Palmetto State Roots Web Site.

© 1998

Cynthia Ridgeway Parker, M.Ed.