Read HTML The Definitive Guide Online
Authors: Chuck Musciano Bill Kennedy
cp source-file dest-file
replacing the source-file with the name of the source file, and dest-file with the name of the destination file.
Figure 4.11: The tag typically appears in preformatted () computer code
Like the other computer programming and documentation-related tags, the tag not only makes it easy for users to understand and browse your documentation, but automated systems might someday use the appropriately tagged text to extract information and useful parameters mentioned in your document. Once again, the more semantic information you provide to your browser, the better it can present that information to the user.
4.4.11 The class, id, style, and title Attributes
Although each content-based 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 content-based tags using either the style or class
attributes. [Inline Styles: The style
Attribute, 9.1.1]
[Style Classes, 9.2.4]
You also may assign a unique identifier to the content-based style tag, as well as a less-rigorous title, using the respective attributes and their accompanying quote-enclosed string values.
[The id attribute, 4.1.1.4]
[The title attribute, 4.1.1.5]
4.4.12 The dir and lang Attributes
The dir attribute advises the browser as to which direction the text within the content-based style tag ought to be displayed, and lang lets you specify the language used within the tag.
[The dir attribute, 3.5.1.1] [The lang attribute, 3.5.1.2]
4.4.13 Event Attributes
Things happen in and around a content-based tags' content, and with the respective "on" attribute and value, you may react to
that event by displaying a user dialog, or activating some multimedia event. [JavaScript Event Handlers, 13.3.3]
4.4.14 Summary of Content-based Tags
The various graphical browsers render text inside content-based tags in similar fashion; text-only browsers like Lynx have consistent styles for the tags.
Table 4.1 summarizes these browsers' display styles for the native tags. However, style sheet
definitions may override these native display styles.
Table 4.1: Content-based Tags
Tag
Netscape
Internet Explorer
Lynx
n/a
n/a
n/a
n/a
n/a
n/a
italic
italic
monospace
monospace monospace
monospace
n/a
italic
n/a
italic
italic
monospace
monospace monospace bold monospace
monospace monospace
monospace
bold
bold
monospace
italic
monospace
monospace
4.4.15 Allowed Content
Any content-based style tag may contain any item allowed in
text
, including conventional text, anchors, images, and line breaks. In addition, other content-based and physical style tags can be embedded within the content.
4.4.16 Allowed Usage
Any content-based style tag may be used anywhere an item allowed in
text
is used. In practice, this means you can use the , , and other like tags anywhere in your HTML document except inside
4.4.17 Combining Content-based Styles
It may have occurred to you to combine two or more of the various content-based styles to create interesting and perhaps even useful hybrids. Thus, an emphatic citation might be achieved with: Moby Dick In practice, Dr. Frankenstein, the browser usually ignores the monster; as you can test by typing and viewing the example yourself, Moby Dick gets the citation without emphasis.
The HTML standard does not require the browser to support every possible combination of content-based styles and does not define how the browser should handle such combinations. Someday, maybe. For now, it's best to choose one tag and be satisfied.
4.3 Changing Text
4.5 Physical Style Tags
Appearance
4.5 Physical Style Tags
There are nine physical styles provided by the current HTML standard, including bold, italic, monospaced, underlined, strike-through, larger, smaller, superscripted, and subscripted text. In addition, to our dismay,
Netscape still supports "blinking" text.[2] All physical style tags require an ending tag.
[2] Once programmed, always a feature, we guess. Internet Explorer has its warts, too.
As we discuss each physical tag in detail, keep in mind that they convey an acute styling for the immediate text.
For more comprehensive, document-wide control of text display, use style sheets (see
Chapter 9
).
Physical Style Tags
Function:
Specify a physical style for 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.5.1 The Tag
The tag is the physical equivalent of the content-based style tag, but without the latter's extended meaning. The tag explicitly boldfaces a character or segment of text that is enclosed between it and its corresponding () end tag. If a boldface font is not available, the browser may use some other representation, such as reverse video or underlining.
4.5.2 The Tag
The tag makes it easy to increase the size of text. It couldn't be simpler: The browser renders the text between the tag and its matching ending tag one font size larger than the surrounding text. If that text is already at the largest size, has no effect.
[, 4.6]