Read HTML The Definitive Guide Online
Authors: Chuck Musciano Bill Kennedy
4.7.5.4 The class, id, style, and title attributes
Although the browsers usually display
content in a defined style, you can override that style and add special effects, such as a background picture, by defining your own style for the tag. This new look can be applied to thetags 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 id to the
tag, as well as a less rigorous title, using the respective attribute and accompanying quote-enclosed string value.
[The id attribute, 4.1.1.4]
[The title attribute,4.7.5.5 Event attributes
Like with most other tagged segments of content, user-related events can happen in and around
content, such as when a user clicks or double-clicks within its display space. Many of these events are recognized by the browser if it conforms to the HTML 4.0 specification (none do fully).With the respective "on" attribute and value, you may react to that event by displaying a user dialog
box or activating some multimedia event. [JavaScript Event Handlers, 13.3.3]4.7.6 The
Tag (Deprecated)
Thetag is another of those whose effects are obvious: content, including text, graphics, tables, and so on, are each centered inside the browser's window. For text, this means that each line, individually, gets centered after the text flow is filled and wrapped. The alignment remains in effect until canceled with its end tag.; never omitted Function:
Center a section of text
Attributes:
ALIGN ONKEYUP
CLASS ONMOUSEDOWN
DIR ONMOUSEMOVE
ID ONMOUSEOUT
LANG ONMOUSEOVER
ONCLICK ONMOUSEUP
ONDBLCLICK STYLE
ONKEYDOWN TITLE
ONKEYPRESS
End tag:
Contains:
body_content
Used in:
block
Line-by-line is a common, albeit primitive, way to center text, and it should be used judiciously.
That's because the browsers do not attempt to balance a centered paragraph or other block-related elements, such as elements in a list. So keep your centered text short and sweet. Titles make good centering candidates; a centered list usually is difficult to follow.
Beyond that, you'll rarely see conventional text centered, except for some lyrical prose, so readers may react badly to large segments of centered prose in your documents. Rather, HTML authors more commonly use
to center a table or image in the display window (there is no explicit center alignment option for inline images or tables, but there are styles-related ways to achieve the effect). Because users will have varying window widths, display resolutions, and so on, you may also want to employ the
and extension tags (see previous descriptions) to keep your centered text intact and looking good. For example:
Copyright 1995 by QuatCo Enterprises.
All rights reserved.
The
tags in the sample source help ensure that the text remains on a single line, and the tag controls where the line may be broken if it exceeds the browser's display window width. Centering also is useful for creating distinctive section headers, although you may now achieve the same effect with an explicit align=center attribute in the respective heading tag. You might also center text using align=center in conjunction with the
ortags. In general, the
tag can be replaced by an equivalent or similar tag and its use should be discouraged.Indeed, like and other HTML 3.2 standard tags that have fallen in disfavor in the wake of style sheets, the
tag is deprecated in the HTML 4.0 standard. Nonetheless, its use in HTML documents is nearly universal, and the popular browsers are sure to support it for many revisions to come. Still, be aware of its eventual demise. 4.7.6.1 The dir and lang attributes
The dir attribute lets you advise the browser as to which direction the text within the
segment ought to be displayed, and lang lets you specify the language used within the tag.
[The dirattribute, 3.5.1.1] [The lang attribute, 3.5.1.2]
4.7.6.2 The class, id, style, and title attributes
Use the style attribute to specify an inline style for thetag, or use the class attribute to apply a predefined style class to the tag.
[Inline Styles: The style Attribute, 9.1.1]
[Style Classes,You may assign a unique id to the
tag, as well as a title, using the respective attribute and
accompanying quote-enclosed string value. [The id attribute, 4.1.1.4]
[The title attribute, 4.1.1.5]4.7.6.3 Event attributes
Like with most other tagged segments of content, user-related events can happen in and around the
tag, such as when a user clicks or double-clicks within its display space. Many of these events are recognized by the browser if it conforms to the HTML 4.0 specification (none do fully). With the respective "on" attribute and value, you may react to that event by displaying a user dialog
box or activating some multimedia event. Section 13.3.3 in
Chapter 134.7.7 The
Tag (Obsolete) Thetag is an obsolete tag, explicitly removed from the HTML 4.0 standard, meaning that you shouldn't use it. We include it here for historical reasons, since it is supported by some browsers and has the same effect on text formatting as the ; never omittedtag with a specified width of 132characters.
Function:
Render a block of text without any formatting Attributes:
CLASS
STYLE
End tag:
Contains:
literal_text
Used in:
block
The only difference between
andis that no other markup is allowed within the tag. So you don't have to replace the literal <, >, and & characters with their entity equivalents in a block as you must inside a block.
Other books
The Autobiography of James T. Kirk by David A. GoodmanWar in Heaven by Charles WilliamsMink River: A Novel by Doyle, BrianFire Storm by Steve SkidmoreThe Unofficial Hunger Games Companion by Lois H. GreshHalloween Party by R.L. StineTruth Lies Bleeding by Tony BlackGideon's Promise (Sons of Judgment Book 2) by Morgana Phoenix, Airicka PhoenixWhen We Touch by Heather GrahamTaken by the Billionaire by Claire, Kendra