HTML The Definitive Guide (33 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
11.29Mb size Format: txt, pdf, ePub

Chapter 4

Text Basics

 

4.4 Content-based Style Tags

It takes discipline to use the content-based styles, since it is easier to simply think of how your text should look, not necessarily what it may also mean. Once you get started using content-based styles, your documents will be more consistent and better lend themselves to automated searching and content compilation.

Content-based Style Tags

Function:

Alter the appearance of text based upon the meaning, context, or usage of the text Attributes:

ALIGN ONKEYUP

CLASS ONMOUSEDOWN

DIR ONMOUSEMOVE

ID ONMOUSEOUT

LANG ONMOUSEOVER

ONCLICK ONMOUSEUP

ONDBLCLICK STYLE

ONKEYDOWN TITLE

ONKEYPRESS

End tag:

Never omitted

Contains:

text

Used in:

text

4.4.1 The Tag

The tag indicates that the enclosed text is an abbreviated form of a longer word or phrase. The browser might use this information to change the way it renders the enclosed text. Since none of the popular browsers yet support this tag first introduced in HTML 4.0, we can't predict how they might implement it.

4.4.2 The Tag

The tag indicates that the enclosed text is an acronym, an abbreviation formed from the first letter of each word in a name or phrase, such as HTML and IBM. None of the popular browsers yet support this HTML 4.0 addition to the stable of content-based style tags, so we can't show you how they might render -tagged text.

4.4.3 The Tag

The tag usually indicates that the enclosed text is a bibliographic citation like a book or magazine title. By
convention, the citation text is rendered in italic. For example, see Figure 4.7
for how Internet Explorer renders this source text: While kumquats are not mentioned in Melville's Moby Dick, it is nonetheless apparent that the mighty cetacean represents the bitter "kumquat-ness" within every man. Indeed, when Ahab spears the beast, its flesh is tough, much like the noble fruit.

Use the tag to set apart any reference to another document, especially those in the traditional media, such as books, magazines, journal articles, and the like. If an online version of the referenced work exists, you also should enclose the citation within the tag and make it a hyperlink to that online version.

Figure 4.7: Internet Explorer renders in italic
The tag also has a hidden feature: it enables you or someone else to automatically extract a bibliography from your documents. It is easy to envision a browser that compiles tables of citations automatically, displaying them as footnotes or as a separate document entirely. The semantics of the tag go far beyond changing the appearance of the enclosed text; they enable the browser to present the content to the user in a variety of useful ways.

4.4.4 The Tag

Software code warriors have become accustomed to a special style of text presentation for their source programs. The tag is for them. It renders the enclosed text in a monospaced, teletype-style font like Courier familiar to most programmers and readers of O'Reilly's series of books, including this one.

This following bit of en
ed text is rendered in monospaced font style by Netscape as shown in Figure 4.8
: The array reference a[i] is identical to the pointer reference *(a+i).

Figure 4.8: Use to present computer-speak
You should use the tag only for text that represents computer source code or other machine-readable content. While the tag usually just makes text appear in a monospaced font, the implication is that it is source code and future browsers may add other display effects. For example, a programmer's browser might look for segments and perform some additional text formatting like special indentation of loops and conditional clauses. If the only effect you desire is a monospaced font, use the tag instead.

4.4.5 The Tag

Use to tag those defining instances of special terms or phrases. It may not result in any formatting changes by the browser. Instead, might assist in creating a document index or glossary.

For example, use the tag to introduce a new phrase to the reader: When analyzing annual crop yields, rind spectroscopy may prove useful. By comparing the relative levels of saturated hydrocarbons in fruit from adjacent trees, rind spectroscopy has been shown to be 87% effective in predicting an outbreak of trunk dropsy in trees under four years old.

Notice that we delimit only the first occurrence of "rind spectroscopy" with a tag in the example. Good style tells us not to clutter the text with highlighted text. As with the many other content-related and physical style tags, the fewer the better.[
1
] As a general style, especially in technical documentation, set off new terms when they are first introduced to help your readers better understand the topic at hand, but resist tagging the terms thereafter.

[1] If you need convincing that less is better when applying the content-based and physical style tags, try reading a college textbook in which someone has highlighted what they considered important words and phrases with a yellow pen.

4.4.6 The Tag

The tag tells the client browser to present the enclosed text with emphasis. For nearly all browsers, this means the text is rendered in italic. For example, the popular browsers will emphasize by italicizing the words "always" and "never" in the following HTML source: Kumquat growers must always refer to kumquats as "the noble fruit," never as just a "fruit."

Adding emphasis to your text is a tricky business. Too little, and the emphatic phrases may be lost. Too much, and you lose the urgency. Like any seasoning, emphasis is best used sparingly.

Although invariably displayed in italic, the tag has broader implications as well and someday browsers may render emphasized text with a different special effect. The tag explicitly italicizes text; use it if all you want is italic. Besides emphasis, also consider using when presenting new terms or as a fixed style when referring to a specific type of term or concept. For instance, one of O'Reilly's book styles is to specially format file and device names. In the HTML version, might be used to differentiate those terms from simple italic for emphasis.

4.4.7 The Tag

Speaking of special style for technical concepts, there is the tag. As you probably already suspect, it is used to indicate text that is typed on a keyboard. Its enclosed text typically is rendered by the browser in monospaced font style.

The tag is most often used in computer-related documentation and manuals, such as in this example: Type quit to exit the utility, or type menu to return to the main menu.

4.4.8 The Tag

The tag indicates a sequence of literal characters that should have no other interpretation by the user. This tag is most often used when a sequence of characters is taken out of its normal context. For example, the following source: The ae character sequence may be converted to the æ ligature if desired.

is rendered by Netscape as shown in Figure 4.9
.

Figure 4.9: Setting off sample text using the tag

(The special HTML reference for the "ae" ligature entity is æ and is converted to its appropriate æ ligature character
by most browsers.) For more information, see Appendix E, Character Entities
.

In general, the tag is not used very often. It should be used in those few cases where special emphasis needs to be placed on small character sequences taken out of their normal context.

4.4.9 The Tag

Like the tag, the tag is for emphasizing text, except with more gusto. Browsers typically display the tag differently than the tag, usually by making the text bold (versus italic), so that users can distinguish between the two. For example, in the following text, the emphasized "never" appears in italic with Internet Explorer, while the "forbidden" is rendered in bold characters (see
Figure 4.10
): One should never make a disparaging remark about the noble fruit. In particular, mentioning kumquats in conjunction with vulgar phrases is expressly forbidden by the Association bylaws.

If common sense tells us that the tag should be used sparingly, the tag should appear in documents even more infrequently. text is like shouting. text is nothing short of a scream. Like a well-chosen epithet voiced by an otherwise taciturn person, restraint in the use of makes its use that much more noticeable and effective.

Figure 4.10: Strong and emphasized text are rendered differently by Internet Explorer
4.4.10 The Tag

The tag, another computer-documentation trick, indicates a variable name or a user-supplied value. The tag is most often used in conjunction with the and

 tags for displaying particular elements of computer programming code samples and the like. -tagged text typically is rendered in monospace font, as shown in
Figure 4.11
, which displays Netscape's rendering of the following example: The user should type

Other books

Roommating (Preston's Mill #1) by Noelle Adams, Samantha Chase
1 Dead in Attic by Chris Rose
High Season by Jon Loomis
Lone Wolves by John Smelcer
City Girl by Judy Griffith Gill
Crashing the Net by Wayland, Samantha
Líbranos del bien by Donna Leon

© 100 Vampire Novels China Edition 2015 - 2024    Contact for me [email protected]