Chapter 47. Controlling the Typeface
Normally, a browser displays text in its default typeface or font, which is almost always Times New Roman on Windows computers. HTML offers the creaky font tag to let you change the typeface for a particular section of text. The font tag works like this:
The value of the face attribute is the name of the font that you want to use.You may play with the position of the font tags to apply the font to several text elements in a row:
<p>
<font face="Arial">This paragraph displays in Arial.</font>
</p>
But now that CSS is here, you don't need the font tag. The font-family attribute performs the same function. You can add it to the style definition of an HTML tag:
<font face="Arial">
<h1>This header displays in Arial.</h1>
<p>So does this paragraph.</p>
<p>So does this paragraph.</p>
</font>
or a class style:
p {
font-family: Arial;
}
CSS makes typeface management easier, too. If you define a style rule so that all paragraphs display in Arial, as in the first CSS example, you can forget about those annoying font tags. Whenever you add a paragraph to your page, it automatically displays in Arial.
.arialtext {
font-family: Arial;
}
TIPIf the name of a font contains multiple words, like Times New Roman or Courier New, make sure you put the name in quotes in the CSS style definition. |
body {
font-family: Arial;
}