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
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

Legal Notices.

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

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