home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next



Table 6.6 The Six General-Purpose Attributes Introduced in HTML 4

Element Function Supported by Netscape Navigator 4 Supported by Internet Explorer 4
CLASS Define a subclass of an HTML element, or elements, for use with formatting style sheets yes yes
DIR Change the text directionality (left-to-right or right-to-left) for an element no no
ID Label an HTML element; for use with formatting style sheets yes yes
ID Label an HTML element; for identifying target IDs for hypertext references no yes
LANG Identify the language of the text within no no the elements
STYLE Specify a specific style sheet rule for the element yes yes
TITLE Specify a text title or label for the element no yes


Figure 6.5 Document illustrating the new “generic” attributes. The attributes CLASS=”under” and ID=”through” associate the style sheet rules (at the top of the document) to the formatting of the associated element. The TITLE attribute of the third paragraph element associates a “tool-tip” text pop-up with the paragraph text. The hypertext link at the top of the document is linked to the final paragraph (ID=”label1”). This link is supported on Internet Explorer 4, but not Netscape Navigator 4.

<HTML>
<HEAD><TITLE> Attribute Tester: TITLE, CLASS, ID, STYLE,
   ID, STYLE, DIR </TITLE>

</HEAD>
<STYLE>
<!--
.under        {text-decoration: underline}    /* rule for underline      */
#through  {text-decoration: line-through}      /* rule for strike-through */
-->
</STYLE>
<BODY BGCOLOR=“white”>
<H3>Attribute Tester: TITLE, CLASS, ID, STYLE, and DIR</H3>

<P>Here is a paragraph. This paragraph contains a
<A HREF=“#label1”>hypertext anchor</A> pointing to the
reference “label1”.  </P>

<P ID=“through”>Here is a paragraph with <B>ID</B>=“through”.
There is a CSS rule associated with this ID value, such that
a browser should render this paragraph with a line struck
through the text.</P>

<P TITLE=“Funny Paragraph”>This paragraph contains an
<EM CLASS=“under”>EM element</EM> of <B>CLASS</B>=“under”.
The associated CSS rule should underline the section of
emphasized text. The paragraph also has the attribute
<B>TITLE</B>=“Funny Paragraph”. </P>

<P>This paragraph has two <B>SPAN</B> elements that use the
<B>DIR</B> attribute to change text directionality.Here
they are:<BR>
<B><TT>DIR=“ltr”:</TT></B> <SPAN DIR=“ltr”>A span of left to right
text</SPAN><BR>
<B><TT>DIR=“rtl”:</TT></B> <SPAN DIR=“rtl”>A span of right to left
text</SPAN></P>

<P ID=“label1”>A final paragraph, of <B>ID</B>=“label1”. The
hypertext reference at the top of the page should link to
here.</P>

</BODY></HTML>


Figure 6.6  Internet Explorer 4.0 rendering of the document listed in Figure 6.5. Notice the struck-through and underlined text, formatted according to the style sheet rules. Note also the “tool-tip” text above the third paragraph—the text is from the paragraph element’s TITLE attribute.

“Event-Handler” Element Attributes

HTML 4 defines 18 special “event-handling” attributes, listed in the following section. Event handling attributes relate HTML elements to script programs that should be run when the corresponding “event” happens to the element. For example, an onMouseOver event occurs whenever the mouse pointer moves on top of an element. Thus if an element has the attribute

onMouseOver=“handler_program()”

then the program handler_program() will be run whenever the mouse moves over the element. The programs themselves must be included within the document and are written in either JavaScript or VBScript.

To mark the special nature of the event handling attributes, they are written in this book in mixed upper- and lowercase. The different HTML 4 attributes are listed in Table 6.7, alongside a list of elements to which they apply. Note, however, that most current browsers do not support all these attributes/element pairs, and also do support several other, nonstandard event handling attributes. For a more detailed description of the level of support for event-handling attributes by current browsers, please read the “Scripting in HTML Documents” section in Chapter 7.

Basic Structure: HTML, HEAD, and BODY

The basic structure of an HTML document is laid out by the HTML, HEAD, and BODY elements.

HTML Element: An HTML Document

Usage: <HTML> ... </HTML>
Can Contain: HEAD, BODY, FRAMESET, NOFRAMES
Can Be Inside: nothing
Attributes: DIR, LANG, VERSION

Table 6.7 Event Handler Attributes and the Associated HTML Elements, as Defined in HTML 4

Attribute Name Relevant HTML Elements
onLoad, onUnload BODY and FRAMESET only
onBlur, onFocus A, BUTTON, LABEL, INPUT, SELECT, and TEXTAREA
onReset, onSubmit FORM
onChange, onSelect INPUT, SELECT, and TEXTAREA
onClick, onDblClick, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp most BODY-content elements


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.