Main

 
Page #16: The Body Beautiful. Part 2: <bgcolor>

index previous page The <body> Beautiful. Part 2: <bgcolor> next page

The code for using a color as your page background is:

<body bgcolor="colorname" OR "hexadecimal color value">

In one of our later classes, I will show you how to deal with that scary- sounding thing called "hexadecimal color value." (It is surprisingly simple. The files "clrbrwsr.exe" and "nclrz32.exe" that you see on the class floppy are there for that purpose. Macintosh users can get similar tools here.) But right now, our task is the bgcolor attribute.

The file textcolors.txt on your class floppy lists more than one hundred color names. The browser may not recognize some of them. If it does not recognize the color name that you have chosen, the browser will usually ignore the attribute and present an unadorned background. In some cases, when the browser does not recognize the color name that you have used, it will "interpret" that color name and give you a totally unexpected result. Example: "LIGHTBROWN." Solution: pick a different name.

The code for the background of the page you are looking at is:

<body bgcolor="lightcyan">


Play Time!

  1. Create a Web page using <body bgcolor="colorname">. Use either "prac11.htm" or "prac14.htm" — which ever one you didn't use in "prac15.htm" — as the starting point for this exercise. Or start from scratch.
  2. You can use the list in the file "textcolors.txt" on your class floppy to choose color names. If you use one of the longer colornames, use copy & paste to transfer the information.
  3. In all your work, pay attention to:
    • Page structure (<html> <head> <body>)
    • Indent lines of code to keep the structure visually clear to your own eye. View the "source" of any of these instructional pages that I have created, and you will see many examples of the way in which I have used indenting to help me keep track of what I am doing. (The browser ignores the indents. It's for us humans.)
  4. With each change, save your work; don't wait until you've finished to save the file. Call it "prac16.htm" or "prac16.html".
  5. Display your work.
  6. Fix any coding errors.