Read HTML The Definitive Guide Online
Authors: Chuck Musciano Bill Kennedy
4.6 Expanded Font Handling
We agonized over including this section here in a prominent position within this chapter, or relegating it to the end. It belongs here because the various tags associated with the extended font model for HTML were part of the 3.2 standard. And they remain very popular with HTML authors, besides being well-supported by all the popular browsers. Yet they have been deprecated in the latest HTML 4.0 standard, warranting banishing the whole section to the end of the chapter with all the implicit red flags.
We suspect the W3C wants authors to use style sheets, not acute tags, for explicit control of font styles, colors, and sizes of the text characters that form your HTML content. That's why these extended font tags and related attributes have fallen into disfavor. Nonetheless, we put this section here because we doubt that the majority of HTML authors will stop using, nor that the popular browsers will any time soon abandon support for, tags that are in such widespread use. Just be aware of their precarious position in the language.
4.6.1 The Extended Font Size Model
Instead of absolute point values, the Extended Font Model of HTML 3.2 as supported by the popular browsers uses a relative model for sizing fonts. Sizes range from 1, the smallest, to 7, the largest; the default (
basefont
) font size is 3.
It is almost impossible to state reliably the actual font sizes used for the various virtual sizes. Most browsers let the user change the physical font size, and the default sizes vary from browser to browser. It may be helpful to know, however, that each virtual size is successively 20 percent larger or smaller than the default font size 3. Thus, font size 4 is 20 percent larger, font size 5 is 40 percent larger, and so on, while font size 2 is 20 percent smaller and font size 1 is 40 percent smaller than font size 3.
4.6.2 The
The
Function:
Define base font size for relative font size changes Attributes:
COLOR
FACE
ID
NAME
SIZE
End tag:
; optionally used
Contains:
Nothing
Used in:
block
,
head_content
The
Internet Explorer supports two additional attributes for the
4.0 also defines the face attribute as a synonym for the name attribute. These attributes control the color and typeface used for the text in a document and are used just like the analogous color and face attributes for the tag, described later.
HTML 4.0 also defines the id attribute for the
for later access to its contents. [The id attribute, 4.1.1.4]
Authors typically include the
In an egregious deviation from the HTML and SGML standards, the browsers interpret the ending tag
not
to terminate the effects of the most recent
The following example source and
Figure 4.13
illustrate how Netscape responds to the
This text should be rather large (size 7).
Ah, back to normal.
Figure 4.13: Playing with
We recommend against ever using ; use
4.6.3 The Tag (Deprecated)
The tag lets you change the size, style, and color of text. We don't recommend that you use it because it has been deprecated in the HTML 4.0 standard. But should you decide to ignore our advice, then use it like any other physical or content-based style tag for changing the appearance of a short segment of text.
Function:
Set the font size for text
Attributes:
CLASS LANG
COLOR SIZE
DIR STYLE
FACE TITLE
ID
End tag:
; always used
Contains:
text
Used in:
text
To control the color of text for the entire document, see the attributes for the
tag described in section 5.3.1.4.6.3.1 The size attribute
The value of the size attribute must be one of the virtual font sizes (1-7) described earlier, defined as an absolute size for the enclosed text or preceded by a plus or minus sign (+ or -) to define a relative font size that the browser adds to or subtracts from the base font size (see the
In general, use absolute size values when you want the rendered text to be an extreme size, either very large or very small, or when you want an entire paragraph of text to be a specific size.
For example, using the largest font for the first character of a paragraph makes for a crude form of
illustrated manuscript (see Figure 4.14):
Call me Ishmael.
Figure 4.14: Exaggerating the first character of a sentence with the size attribute for
Also, use an absolute font when inserting a delightfully unreadable bit of "fine" print - boilerplate or
legalese - at the bottom of your documents (see Figure 4.15
):
All rights reserved. Unauthorized redistribution of this document is prohibited. Opinions expressed herein are those of the authors, not the Internet Service Provider.
Figure 4.15: Use the tiniest font for boilerplate text
Except for the extremes, use relative font sizes to render text in a size different than the surrounding text, to emphasize a word or phrase, for example (see
Figure 4.16
):
Make sure you always sign and date the form!