T
o specify the font size, use the sizeattribute of the <font>tag. The sizeattribute accepts a numeric value from one of two scales: the absolute or rela- tive scale.
1. To define the font size for a preexisting <font>tag, simply add a size attribute set equal to your chosen value. Figure 14-1 shows what the following code looks like in your browser.
<p> <font face=”Arial, Helvetica, sans-serif” size=”2”>All text affected by this font tag is now set to size
2.</font> </p>
<p> <font face=”Arial, Helvetica, sans-serif”>All text affected by this font tag is defaulting to the browser’s base font size, because no size attribute is
defined.</font> </p>
Figure 14-1:A font size of 2, in contrast to undefined font size
2. You can control the font size by simply adding a <font>tag with just
the sizeattribute defined. The following code changes the font size of the word here to 5. Figure 14-2 shows what it looks like in your browser.
<p> <font face=”Arial, Helvetica, sans-serif” size=”2”>All text affected by this font tag is now set to size 2. Except this word <font size=”5”>here</font>, around which I’ve nested a second font tag with a different size setting.</font> </p>
<p> <font face=”Arial, Helvetica, sans-serif”>All text affected by this font tag is defaulting to the browser’s base font size, because no size attribute is
defined.</font> </p>
3. To define the base font size for your entire document, enter the
<basefont>tag just below the opening <body>tag and set its size
attribute to a value from 1 to 7:
<basefont size=”2”>
Figure 14-2:The word hereaugmented by a second font size value
notes
•
The absolute scale ranges from 1 (the smallest) to 7 (the largest). A size value of 3 is the same as the browser’s current default font size (also called thebasefont size). Provided the user hasn’t modified the default browser set- tings, this makes a size 3 equal to 12-point text. The rest of the scale con- verts as follows: 1 = 7.5pt., 2 = 10pt., 4 = 13.5pt., 5 = 18pt., 6 = 24pt., and 7 = 36pt.
•
The relativescale runs from –7 to +7 and sets the font size in relation to the base font of the browser. So set- ting the font size to +1 makes the text appear one size larger than the base font size. This is why you use a relative font size value in conjunction with an absolute base font value. Otherwise, you have no idea what the browser is using for the base font size.Task
14
caution
•
The relative scale doesn’t allow you to display a font size outside of the absolute scale of 1 through 7. The browser’s base font size always equals a font size of 3, regardless how the user sets the point value. Therefore, you cannot apply a relative size value that adds to more than 7 or sub- tracts to less than 1 from the current font size you’ve set. The relative scale is best used in conjunction with the<basefont>tag, with which you can force a font size for an entire document.
tips
•
Because a user can change the default font size setting, the absolute scale isn’t exactly “absolute”; any font size value you define with it will still be relative to the user’s base font size. If this seems like too much to worry about, just remember that size 1 is really tiny and size 7 is really big. Size 2 is the most common because it’s small enough to allow you to fit plenty of text into a page, while being large enough so that most folks don’t have to squint to read it.•
Remember that the browser’s default font size is equal to a base font value of 3. So entering<basefont size=“3”>
is the same as entering nothing at all. Just like the <font>tag, the
<basefont>tag is deprecated in HTML 4.0 through the current XHTML standard, in favor of CSS (see Part 9).
4. With the <basefont>tag and sizeattribute defined, use the relative scale to increase or decrease individual regions of text. Figure 14-3 shows what this code looks like in your browser.
<basefont size=”2”>
<p>All text in this document will default to size 2. <font size=”+3”>T</font>he first letter in this sentence has now been punched up to a size 5 using a +3 size value. </p>
Figure 14-3:The Tincreased to a font size of 5 using a relative +3 value 5. To make a region of text one size larger than the surrounding text,
wrap it inside the <big>and </big>tags. You can make this addi-
tive by using multiple <big>tags. To make the text smaller, use
<small>and </small>tags. Figure 14-4 shows what the code
looks like in your browser.
<p> We’ve made this word three times
<big><big><big>bigger</big></big></big> by nesting it inside three sets of big tags.</p>
<p> <font size=”5”>We’ve made this word three times <small><small><small>smaller</small></small></small> by nesting it inside three sets of small tags.</font></p>
Figure 14-4:Multiple <big> and <small> tags with their cumulative effects