Maddog's HTML for Real People Chapter 5, Lesson 5


[INDEX] Ch 5, L 5 - Color Names

If you already know how to specify colors using color names, and when not to do so, you can skip this lesson.

We've had quite a bit of practice now with specifying color attributes in HTML. Now, I know using attributes themselves is pretty straight-forward, but whataya think about those RGB-codes? Yeah, that's what I thought. Well, you're not the first person to find RGB codes unfriendly, and so the HTML uppity-ups deigned to make a large concession for us Real People. The latest version of HTML provides the option for use of color names in the attribute value.

You're already familiar with the color names; they're the names that correspond to our 16-color pallette. To use the color names instead of the RGB-code, apply them to the tag like this:

COLOR="color-name"

As an example, let's say we want a "navy" font. we can do it by RGB-code, or by color-name. Here's how both are done:

by RGB-code: <FONT COLOR="#000080"></FONT>
by color-name: <FONT COLOR="navy"></FONT>

Let's take notice of a few things. First, these two tags make the browser behave identically. Second, the tags are identical except for what is placed inside the quotation marks as the 'COLOR' attribute's value. Finally, notice that the '#' sign is not required when using the color name.

Remember the demonstration we did in an earlier lesson, in which we displayed all the color names in their own color? In that source code, we used RGB-codes throughout. Let's do it again, using color names, and see what happens:

HTML Source Code Follows:


<B>
<FONT Color="black">black</FONT> 
<FONT Color="white">white</FONT> 
<FONT Color="silver">silver</FONT>      
<FONT Color="gray">gray</FONT> 
<FONT Color="red">red</FONT>       
<FONT Color="maroon">maroon</FONT> 
<FONT Color="fuchsia">fuchsia</FONT>      
<FONT Color="purple">purple</FONT>
<P> 
<FONT Color="blue">blue</FONT>         
<FONT Color="navy">navy</FONT> 
<FONT Color="aqua">aqua</FONT> 
<FONT Color="teal">teal</FONT> 
<FONT Color="lime">lime</FONT>       
<FONT Color="green">green</FONT> 
<FONT Color="yellow">yellow</FONT> 
<FONT Color="olive">olive</FONT> 
</B>    
(End of HTML Source Code)

Demonstration Follows:

black white silver gray red maroon fuchsia purple

blue navy aqua teal lime green yellow olive

(Demonstartion Ends)

If you didn't see all the colors displayed, your browser probably doesn't support the use of "color names". Believe me, you're not alone. Since the use of color names is a fairly recent addition to HTML, there are still an awfully lot of browsers that don't have that option. That's why I recommend NOT using color names, even though they are quite convenient. In a year or two, the vast majority of browsers will have upgraded to having the capability of interpreting color names, but until then, I think we're better off using the dreaded RGB-code.

The color name features are likely to continue expanding. Netscape, in its latest version, has expanded the list to over a hundred color names. You can view one version of the expanded list at http://colors.infi.net/colorindex.html or http://colors.infi.net/cell2.html (text).


-PREVIOUS- -CHAPTER- -INDEX- -NEXT-

Overseer: Monty Northrup ... maddog@io.com ... leave e-mail ...
...to maddog 'n' miracles homepage...