HTML XHTML The Complete Reference
home » reference » appendix d

Appendix D

This appendix contains a quick reference for the commonly available fonts and a brief discussion of downloadable fonts.

Specifying Fonts

Under HTML 4.01 and transitional XHTML 1.0, you can use the tag to set a font in a page by setting the face attribute:

<font face="Britannic Bold">
  This is important

The Web browser reads this HTML fragment and renders the text in the font named in the face attribute-but only for users who have the font installed on their systems. Multiple fonts can be listed using the face attribute:

<font face="Arial, Helvetica, Sans-serif">
  This should be in a different font

Here, the browser reads the comma-delimited list of fonts until it finds a font it supports. Given the fragment shown here, the browser would first try Arial, then Helvetica, and finally a sans-serif font before giving up and using the current browser font.

CSS supports the same approach to setting fonts using font-family and font properties. For example, to set the font to Arial for all text in paragraph tags, you would use a rule like the following:

p {font-family: Arial;}

Of course, the same restriction of fonts available on the local system applies, so a comma-delimited list of fonts should be specified like so:

p {font-family: Verdana, Arial, Helvetica, Sans-serif;}

Regardless of the approach, you can apply a little guesswork to use fonts properly if you consider that most Macintosh, Windows, and UNIX users have a standard set of fonts. If equivalent fonts are specified, it may be possible to provide similar page renderings across platforms.

(X)HTML Elements
CSS Properties
< Home | About | Chapters | Examples | Errata | Reference | Site Map >