HTML: The Definitive Guide

Previous Chapter 4
Text Basics
Next
 

4.5 Physical Style Tags

There are ten physical styles provided by the current HTML standard, including bold, italic, monospaced, underlined, and strike-through text. In addition, the modern browsers support blinking, larger, smaller, superscript, and subscript text. All physical style tags require an ending tag.

The <b> Tag

The <b> tag is the physical equivalent of the <strong> content-based style tag, but without the latter's extended meaning. The <b> tag explicitly boldfaces a character or segment of text that is enclosed between it and its corresponding (</b>) end tag. If a boldface font is not available, the browser may use some other representation, such as reverse video or underlining.

The <big> Tag

The <big> tag makes it easy to increase the size of text without worrying about all of the details of virtual font sizes available with the <font> tag described later in this chapter. It couldn't be simpler: The browser renders the text between the <big> tag and its matching </big> ending tag one font size larger than the surrounding text. If that text is already at the largest size, <big> has no effect. [the section called "The <font> Tag"]

Even better, you can nest <big> tags to enlarge the text. Each <big> tag makes the text one size larger, up to a limit of size seven, as defined by the font model.

Be careful with your use of the <big> tag, though. Because browsers are quite forgiving and try hard to understand a tag, those that don't support <big> often interpret it to mean bold.

The <blink> Tag

Text contained between the <blink> tag and its end tag </blink> does just that: blink on and off. Netscape for Macintosh, for example, simply and reiteratively reverses the background and foreground colors for the <blink> enclosed text. The HTML standard does not include <blink>; it is supported as an extension by Netscape.

We cannot effectively reproduce the animated effect here in these static pages, but it is easy to imagine and probably best left to the imagination, too. That's because blinking text has two primary effects: it gets your reader's attention, and then promptly annoys them to no end. Blinking text should be used sparingly in any context.

The <i> Tag

The <i> tag is like the <em> content-based style tag. It and its necessary (</i>) end tag tell the browser to render the enclosed text in an italic or oblique typeface. If the typeface is not available to the browser, highlighting, reverse video, or underlining might be used.

The <small> Tag

The <small> tag works just like its <big> counterpart (see previous description), except it decreases the size of text instead of increasing it. If the enclosed text is already at the smallest size supported by the font model, <small> has no effect.

Like <big>, you may also nest <small> tags to sequentially shrink text. Each <small> tag makes the text one size smaller than the containing <small> tag, down to a limit of size one.

The <s> Tag

The <s> tag is an abbreviated form of the <strike> tag supported by both Internet Explorer and Netscape.

The <strike> Tag

Most browsers will put a line through ("strike through") text that appears inside the <strike> tag and its </strike> end tag. Presumably, it is an editing markup that tells the reader to ignore the text passage, reminiscent of the days before typewriter correction tape. You'll rarely, if ever, see the tag in use today, but expect it to become more commonplace as marketers of consumer items hawked on the Web slash prices on their slow-moving products.

The <sub> Tag

The text contained between the <sub> tag and its </sub> end tag gets displayed half a character's height lower, but in the same font and size as the current text flow. Both <sub> and its <sup> counterpart are useful for math equations and in scientific notation, as well as with chemical formulæ.

The <sup> Tag

The <sup> tag and its </sup> end tag superscripts the enclosed text; it gets displayed half a character's height higher, but in the same font and size as the current text flow. This tag is useful for adding footnotes to your documents, along with exponential values in equations. In combination with the <a> tag, you can create nice, hyperlinked footnotes:

The larval quat 
weevil<a href="footnotes.html#note74"><sup><small>74</small></sup></a> is a

This example assumes that footnotes.html contains all your footnotes, appropriately delimited as named document fragments.

The <tt> Tag

In a manner like the <code> and <kbd> tags, the <tt> tag and necessary </tt> end tag direct the browser to display the enclosed text in a monospaced typeface. For those browsers that already use a monospaced typeface, this tag may make no discernible change in the presentation of the text.

The <u> Tag

This tag tells the browser to underline the text contained between the <u> and the corresponding </u> tag. The underlining technique is simplistic, drawing the line under spaces and punctuation as well as the text.

The style and class Attributes

Although each physical tag has a defined style, you can override that style by defining your own look for each tag. This new look can be applied to the physical tags using either the style or class attributes. [the section called "Inline Styles: The style Attribute"] [the section called "Style Classes"]

Summary of Physical Style Tags

The various graphical browsers render text inside the physical style tags in similar fashion. Table 4.2 summarizes these browser's display styles for the native tags. Style sheet definitions may override these native display styles.

The following HTML source example illustrates some of the various physical tags as rendered by Netscape for Figure 4.12:

Explicitly <b>boldfaced</b>, <i>italicized</i>, or
<tt>teletype-style</tt> text should be used 
<big><big>sparingly</big></big>.
Otherwise, drink <strike>lots</strike> 1x10<sup>6</sup>
drops of H<sub><small><small>2</small></small></sub>O.

Table 4.2: Physical style tags
Tag Meaning Display Style
<b> Bold contents bold
<big> Increased font size bigger text
<blink> Alternating fore and background colors blinking text
<i> Italic contents italic
<small> Decreased font size smaller text
<s>, <strike> Strike-through text strike
<sub> Subscripted text subscript
<sup> Superscripted text superscript
<tt> Teletypewriter style monospaced
<u> Underlined contents underlined

Allowed Content

Any physical style tag may contain any item allowed in text, including conventional text, anchors, images, and line breaks. You also can combine physical style tags with other content-based ones.

Allowed Usage

Any physical style tag may be used anywhere an item allowed in text can be used. In general, this means anywhere within a document except in the <title>, <listing>, and <xmp> tags. You could use a physical style tag in a heading, but the browser will probably override and ignore its effect in lieu of the heading tag.

Combining Physical Styles

You probably will have better luck, Dr. Frankenstein, combining physical tags than you might have combining content-based tags to achieve multiple effects. For instance, Netscape renders the following in bold and italic typeface:

<b><i>Thar she blows!</i></b>

In practice, other browsers may elect to ignore such nesting. The HTML 3.2 standard does require the browser to "do their best" to support every possible combination of styles, but does not define how the browser should handle such combinations. Although most browsers make a good attempt at doing so, do not assume that all combinations will be available to you.


Previous Home Next
Content-Based Style Tags Book Index Expanded Font Handling

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell