Color can be used in several places within an HTML document. The most
important ones are the use of color in the font tag and in the bgcolor
attribute of the body tag. Each color is represented with three
two-digit numbers, representing the various levels of the primary
colors, Red, Green, and Blue. However, the numbering system used is
based on the hexadecimal system.
In a decimal system, the 10 basic
digits are 0, 1, 2, ...,9 and then the next number (i.,e., 10) is
constructed using the digits 1, and 0 and so on. Therefore, a two digit
number in decimal system can represent at most 100 distinct numbers (from
0-99). In the hexadecimal system there are 16 basic digits, 0, 1, 2, 3,
...,
9, a, b, c, d, e, and f. It is only after the digit f that we start
to create new numbers using double digits. For example 10 in hexadecimal
is equivalent to 17 in decimal.
Confused? Well, you are not
alone. Help is available when you need it in a form of a very useful Java
applet in the Resource Center. Just click on the Resource Center in the
course main homepage. Then click on Background Color Index link on the
left frame and on the right frame and a nifty Java applet will be
displayed. As you click on the larger window with different color
levels, the selected color value and its color are displayed in the lower
window. you can even hold the left mouse button and slide the cursor
over the larger window and watch as the color changes in the lower window.
We will now study Two HTML tags that involve setting color in our HTML
documents.
Font
The font tag sets the color, font, and size of text and uses the following
format:
<FONT COLOR=#color FACE=name SIZE=n>
Where the color can be either a hexadecimal, red-green-blue
color value or a predefined color name such as red, blue, green, yellow,
pink, and so on. My recommendation is to always use the hexadecimal
numbers because earlier browsers may have difficulty with the name color
that you are defining. The name sets a specific font to display
a text defined with the font tag. You can use several type of fonts at
the same time. But because the font availability is dependent upon the
computer used to browse the document, from a list of fonts that you
specify, the browser will search the first font name in the list that
exists on the computer. If none of the fonts are available, it will
display the default font. Finally the n value specifies font size
between 1 and 7 with 7 being the largest. We can also use a plus (+) or
minus (-) sign before the number to indicate a size relative to the
current basefont setting.
Below is an example of the use of the font tag.
<font size=+3>R</font>esistance to <font
color=#ffdd54>change</font> is a <font
face="GaramondBold, Roman, Courier, Helvetica">dominant</font>factor in
nearly
<font size=-2 color=#0000ff >all </font> information systems
implementation.
actually showing up as:
Resistance to change is a
dominant
factor in nearly all information systems
implementations.
|
Body
The body tag specifies the beginning and the end of the document body
and in its most widely used form uses the following format:
<BODY BACKGROUND=url BGCOLOR=color
LINK=color TEXT=color VLINK=color>
Where the color sets the color of text on the page in TEXT, the
color of hyperlinks that have not yet been visited in LINK, the color of an
already visited hyperlink in VLINK, and the background color of the page BGCOLOR. The url
value in BACKGROUND specifies a background picture which will be tiled
behind the text and graphics on the page Usually only one of the two (BACKGROUND
or BGCOLOR is used).
In specifying the colors in the BODY tag, you need to use special care.
Background pictures are specially a major impediment, if not chosen
carefully. They do not let you see the text and the information which is
presented on the page. And just because background pictures usually
involve many colors, it is extremely hard to define a text color that has
a good contrast with the background. I usually do not use background
images, but for the few that I use you can check them in the Resource Center.
In identifying the color for BGCOLOR, TEXT, LINK, and VLINK,
aside from your own preference, the contrast level between the BGCOLOR
value and the others must be high enough to create an easily
recognizable text. A good site that you may want to bookmark for your
reference is the Hexadecimal Color
Index at Infi.net which shows the contrast levels of a specific
background that you select with eight different text colors. They are,
black (000000), red (ff0000), green (00ff00), blue (0000ff), yellow
(ffff00), magenta (ff00ff), cyan (00ffff), and white (ffffff). [Note: This site
is no longer available, but search over the Internet and you will find many
similar pages. Here is
an example ].
Finally, I want you to take a look at
this
page and compare the background with its
alternative page. As you scroll down the page, do you notice any
difference? What do think has caused the difference?