The Wayback Machine - https://web.archive.org/web/20090207063603/http://www.webreference.com:80/html/tutorial23/1.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / html / tutorials / 23 / 1

index1234

Tutorial 23: The Font of Foulness, Part II: Many Faces, Many Colors

Developer News
Open Source ECM Growing Up
Android's Second Act, G2 Rumors Heat Up
Eclipse Rolls Out PHP Development Tools 2.0

FONT and COLOR

The second most widely used attribute that can be applied to the FONT element is COLOR. Unsurprisingly, this lets you control the color of the text contained within the element.

The color is specified in the form of a hash sign (#) followed by six hexadecimal digits. The first pair of digits represent the amount of red, the second pair the amount of green, and the third pair the amount of blue used to mix the color required. This way of specifying colors is exactly identical to one of the syntaxes used in CSS, which we covered in Tutorial 8.

What naturally follows from the above is that (drumroll...) you can use the CSS color property to replicate the behaviour of the COLOR attribute. So the following statements will have the same visual effects on both Internet Explorer and Navigator:

<P><FONT COLOR="#FF0000">This is some text. 
   It is red.</FONT></P>
<P STYLE="color: #FF0000">This is some text. 
   It is also red.</P>
<P STYLE="color: rgb(255,0,0)">This is some text. 
   It, too, is red.</P>
<P STYLE="color: rgb(100%,0,0)">This is some text. 
   Guess what? It's red.</P>

This is some text. It is red.

This is some text. It is also red.

This is some text. It, too, is red.

This is some text. Guess what? It's red.

The color property is surprisingly well implemented in both Internet Explorer and Navigator (if we had bugs even there, we'd be in real trouble) so this replacement should be fine for all your needs.

Since we're on the subject of color, remember back in Tutorial 8 when I mentioned that it's a bad idea for you to specify text colors without specifying background colors as well? This wasn't just a random observation. People have made this mistake a whole lot since color was introduced to the Web, and other people have told them not to do it a whole lot, and the first people haven't listened and still do it. A whole lot. But this is a tutorial that teaches HTML and CSS, not the pitfalls of using bright ochre text on a diseased lilac background. But since the problems of people with no taste in color predate CSS, you must be wondering how background colors were specified before CSS. Funny you should mention that...

index1234

http://www.internet.com/

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Building a Client-Side Ajax Cache · Using Dojo for Client-Side Validation · Apache Basics, Visited
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Research Points to Slow Rate of SSD Transition · Box.Net Unwraps Social Network Features · How-To Guide: E-Commerce Marketing on Facebook

Legal Notices.

URL: http://www.webreference.com/html/tutorial23/1.html

Produced by Stephanos Piperoglou
Created: June 29, 2000
Revised: June 29, 2000

Morty Proxy This is a proxified and sanitized view of the page, visit original site.