| [ Prev ] [ Index ] [ Next ] |
HTML background colours are formed by adding a BGCOLOR attribute to the <BODY> tag.
The BGCOLOR attribute and the 4 text-color atributes (TEXT, LINK, ALINK and VLINK) take rgb values in the form #rrggbb. Each red, green and blue value is a hexadecimal value between 0-255. Black is #000000 and white is #FFFFFF. Any value with identical rr,gg,bb parts is a shade of grey.
Thus a dark blue background is written: <BODY BGCOLOR="#00007F"> (7F=127 or half-value) while light blue is #0000FF (FF=255 or full-value). Mixing colours is an additive process - the larger the value, the more light is going into the final colour.
The total number of colours available will depend on the exact set-up of the viewing system (ie. whether 16-colour or 64-colour etc), but here is a table of common rgb values:
| Color: | (Dark) | (Medium) | (Bright) |
|---|---|---|---|
| Red | #400000 | #7F0000 | #FF0000 |
| Yellow | #404000 | #7F7F00 | #FFFF00 |
| Green | #004000 | #007F00 | #00FF00 |
| Cyan | #004040 | #007F7F | #00FFFF |
| Blue | #000040 | #00007F | #0000FF |
| Magenta | #400040 | #7F007F | #FF00FF |
Here is a body tag specifying a LIGHT YELLOW page background with DARK GREEN text and BRIGHT PINK link-text (changing to MEDIUM GREY if the link has been visited recently - make two visits to the example below and you will notice the change in link-text colour):
<BODY BGCOLOR="#FFFF7F" TEXT="#004000" LINK="#FF00A0" VLINK="#A0A0A0">