Background and Text Colors

WARNING: These pages are written for Netscape 1.1. I don't know how many of these techniques will even work with other browsers.

Guide to Hacking HTML, which covers this topic as well as some other tricks.

You can specify colors for the background, normal text, links, and previously visited links. They can only be set once per page (as far as I know- please mail me if you know a way to get around this!), in the <BODY> command that should be near the top of every page. For those of you more experienced with computers, stick with me while I explain things like Hex and RGB.

To set colors, you have to be able to write hexadecimal numbers. Hex numbers are base 16 numbers, as opposed to base ten. There are sixteen digits; 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F, where A .. F equal 10 .. 15 in decimal. Like the ones place and the tens place in decimal, there are a ones place and a sixteens place in hexadecimal. The hex number A4 is 164 in decimal- the A is a ten in the sixteens place, or 160, and the 4 is a 4 in the ones place. LIkewise, 8B is equal to 139 (8*16+11) and F0 is equal to 239 (15*16). A pair of hexadecimal digits can range from 0 (00) to 255 (FF).

## Putting it together

You tell the web browser reading your page what colors to use with a <BODY> command. The top of your page should have a specified header, where the title goes, and a body, where everything else goes. Inside the header command, you specify colors with the identifiers "bgcolor", "text", "link", and "vlink", for previously visited links. A formatted page, with colors the same as this one, would look like this:

```<HTML>

</BODY>
</HTML>
```

That's about all there is to it. From here, you may want to go on to learn how to put images in the background or do something really funky: flash some colors at the user when they load your page.

Setting Colors Page / Evan Dorn/ evan@sccs.swarthmore.edu
Last Updated January 22, 1996