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


DIV Element: A Block Division of the BODY

Usage: <DIV> ... </DIV>
Can Contain: ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV, DL, FIELDSET, FORM, Hn, HR, [ISINDEX], MENU, NOFRAMES, NOSCRIPT, OL, P, PRE, TABLE, UL,
characters, character highlighting, A, APPLET, BASEFONT, BR, BUTTON, IFRAME, IMG, INPUT, LABEL, MAP, OBJECT, SCRIPT, SELECT, TEXTAREA
Can Be Inside: BLOCKQUOTE, BODY, CENTER, DD, DIV, FIELDSET, FORM, LI, NOFRAMES, NOSCRIPT, TD, TH,
APPLET, BUTTON, IFRAME, OBJECT
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers, ALIGN

DIV marks a block of the document as a logical group or division and is used to specify generic properties for an entire block. DIV supports the standard “generic” and “event-handler” attributes described earlier in this chapter. Note that the event handlers are only partially supported by Internet Explorer 4 and are not supported by Netscape Navigator 4.

DIV can also take an ALIGN attribute, to specify the desired text alignment within the block or within any other block element within the block. The allowed values are “left,” “center,” “right,” and “justify,” which call for left-aligned, center-aligned, right-aligned, and fully justified text, respectively. Note that many browsers do not support justified text. Text alignment can also be specified using a style sheet, as discussed in Chapter 7.

DIV implies the end of any paragraph and will cause a line break in the text. Other than this, DIV does not affect the formatting or presentation of a document (i.e., it does not add any extra vertical spacing) and is simply used to more formally organize the document content. Figure 6.13 and Figure 6.14 show an example of this use of DIV.

Hn Elements: Headings

Usage: <Hn> ... </Hn>
Can Contain: characters, character highlighting, A, APPLET, BASEFONT, BR, BUTTON, IFRAME, IMG, INPUT, LABEL, MAP, OBJECT, SCRIPT, SELECT, TEXTAREA
Can Be Inside: BLOCKQUOTE, BODY, CENTER, DD, DIV, FIELDSET, FORM, LI, NOFRAMES, NOSCRIPT, TD, TH,
APPLET, BUTTON, IFRAME, OBJECT
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers

The elements H1 through H6 denote headings. There is no forced hierarchy in these headings, but for consistency you should use the top level (H1) for main headings and lower levels for progressively less important ones. You should also avoid skipping heading levels within a document, as this breaks the logical structure and may cause problems when converting the document into another form or when automatically generating HTML table of contents documents.


TIP: Avoid Using Headings Just to Get Large Text

Because headings are often used to construct document indexes and databases, you should not using headings simply to obtain large-font text. The FONT element, or SPAN (plus style sheets), provide much better ways of accomplishing the same thing, without affecting the indexing of your work.


Renderings of headings are very much browser-dependent. Most graphical browsers left-adjust headings and use progressively smaller fonts as heading importance decreases (from H1 to H6). Others, such as lynx, render H1 headings as capitalized strings centered on the page. Examples are shown in figures throughout this chapter.

As a general rule, hypertext documents should be broken up such that each page does not occupy more than one or two browser screen areas. Across the collection of pages, you can then use H1 or H2 elements to mark the main headings for the collection and H3 and greater to mark subheadings. Using heading elements consistently across the documents makes it easy for a user (or indexing software) to distinguish the relative position of a section—or an entire document—with respect to the entire collection.

Heading elements support the standard “generic” and “event-handler” attributes described earlier in this chapter. Note that the event handlers are only partially supported by Internet Explorer 4 and are not supported by Netscape Navigator 4.

Headings also support an optional ALIGN attribute, which can take the values “left,” “center,” “right,” and “justify.” The value “left” left-justifies the title flush with the left margin (this is the default), while the value “right” flushes the title to the right window margin. The value “center” causes the heading to be centered on the display window. The value “justify” calls for text to be justified between the left and right margins, falling back to left alignment when the heading is too short—this alignment is not widely supported. Examples of aligned headings are shown throughout this chapter. Note that HTML 4 recommends using a style sheet, rather than the ALIGN attribute, to define alignment.

HR Element: Horizontal Rule

Usage: <HR>
Can Contain: empty
Can Be Inside: BLOCKQUOTE, BODY, CENTER, DD, DIV, FIELDSET, FORM, LI, NOFRAMES, NOSCRIPT, TD, TH,
APPLET, BUTTON, IFRAME, OBJECT
Attributes: CLASS, ID, STYLE, TITLE, standard event handlers
ALIGN, (COLOR: Internet Explorer only), NOSHADE, SIZE, WIDTH

The empty HR element draws a horizontal line across the screen and is often used to divide sections within a single document. An <HR> terminates any preceding paragraph, so a new paragraph mark should follow an <HR> if there is subsequent text that is part of a paragraph. One common design is to place an <HR> at the bottom of a document, followed by an ADDRESS element containing address information for the document maintainer or owner. This is illustrated in Figures 6.7 through 6.10.

HR supports the standard “generic” and “event-handler” attributes described earlier in this chapter. Note that the event handlers are only partially supported by Internet Explorer 4 and are not supported by Netscape Navigator 4.

HR also supports several other attributes that define formatting properties of the rule. These attributes are:

ALIGN=“left,” “right,” “center” (optional) If an HR does not span the page, then it can, like a heading, be aligned on the page. The alignment is controlled by the ALIGN attribute, which can take the values “left,” “right,” or “center” (center is the default).


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.