Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Choosing a Typeface

With the 3 and 4 versions of both Navigator and Internet Explorer, Netscape and Microsoft have added another extremely powerful form of font control: the <font face> attribute. This allows you to specify the actual typeface that should be used to display text—and has been the source of much rejoicing among Webmasters who are awfully sick of Times and Courier!

The page in Figures 6.3 and 6.4 uses these font controls to present a quick but colorful history lesson. Notice how <font> tags can be nested inside one another, changing some aspects of the font's appearance while leaving others the same; for example, even when <font> tags change the size and color of the letters in A HISTORY OF EVERYTHING, the typeface specified in the first <font> tag still applies. Likewise, the <font> tags that make small capital letters do not change the color, so the entire line ends up maroon.

06fig04.jpg

Figure 6.4 If you have the Lucida Sans Unicode and Lucida Sans fonts installed on your computer, they will be used to display the page. Now look at Figure 6.5.

The following is the code to set the typeface used for most of the text in Figure 6.3:

<font face="lucida sans unicode, arial, helvetica">

If Netscape Navigator or Microsoft Internet Explorer can find a font named Lucida Sans Unicode on a user's system, that font is used. Otherwise, the browser will look for Arial or Helvetica. Figure 6.5 shows how the page would look on a computer that didn't have Lucida Sans Unicode or Lucida Sans installed, but did have the Arial font.

06fig05.jpg

Figure 6.5 If you didn't have Lucida Sans Unicode and Lucida Sans fonts installed, the text from Figure 6.3 would appear in Arial, if available, or in the default font, which is usually Times New Roman.

If none of those fonts could be found, the browser would display the text using the default font (usually Times New Roman). Most browsers other than Navigator and Internet Explorer will ignore the font face attribute and display the fonts they always use.

Since only fonts that each user has on his system show up, you have no real control over which fonts appear on your pages. Furthermore, the exact spelling of the font names is important, and many common fonts go by several slightly different names. This means that about the only truly reliable choices are Arial (on Windows machines) and Helvetica (on Macintoshes). Don't be afraid to specify other fonts, but make sure your pages look acceptable in Times New Roman as well.

You'll find many additional tips on using typefaces in Hour 16.

Share ThisShare This

Informit Network