Click Here!
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



Figure 6.9 HTML example document illustrating TITLE, heading, and ADDRESS elements. Figure 6.10 shows this document viewed by Internet Explorer 3.

<HTML>
<HEAD>
<TITLE> Some examples of ADDRESS and heading elements </TITLE>
</HEAD>
<BODY>

<H1 ALIGN=“center”> Example 3: The Truth About Santa  </H1>
<P> Breaking the news to a small child that Santa Claus is
merely a tool of the modern capitalist is one of
the saddest moments in raising children.  Nevertheless, such
truths must be brought to life, for fear that your child
become another Pangloss lost in the idealism so prevalent
amongst our youth. Here are some different methods to
introduce this topic.

<H2 ALIGN=“left”> Santa’s Exploitation of the Working Class </H2>
<P>  Begin by talking about Santa’s enslaved workforce.  How
can those poor gnomes make all those gifts?  Clearly
by driven overwork.....

<H3> Elves and the Union Movement </H3>
<P> and so on.......

<H4> Elf Exploitation </H4>
<P> And still more text.

ltHR>
<ADDRESS>
Santa Claus<BR>
Christmas Holiday Specialist <BR>
North Pole, CANADA H0H 0H0<BR>
Tel: (555) 555 POLE
</ADDRESS>
</BODY> </HTML>


Figure 6.10  Display, by the Internet Explorer 3 browser, of the document shown in Figure 6.9.

BLOCKQUOTE Element: Block Quotations

Usage: <BLOCKQUOTE> ... </BLOCKQUOTE>
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,
Can Be Inside: APPLET, BUTTON, IFRAME, OBJECT
Attributes: CITE, CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers

BLOCKQUOTE marks a block of text as a quotation. Browsers can render this in various ways: for example, by indenting the BLOCKQUOTE content and by offsetting it from the preceding and following text. A BLOCKQUOTE also causes a paragraph break and terminates preceding paragraphs.

Ideally, you should not place text directly inside a BLOCKQUOTE; rather, the HTML 4 specification recommends that text be placed inside other elements (such as paragraphs and lists) that are in turn inside the BLOCKQUOTE. Thus, the form:

<BLOCKQUOTE>
<P> This is the quotation. ...
.....
</P>
</BLOCKQUOTE>

is better than:

 <BLOCKQUOTE>
This is the quotation. ...
.....
</BLOCKQUOTE>

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. BLOCKQUOTE also supports an optional CITE attribute, which takes as its value a URL that references the source of the citation. There are no current Web browsers that support the CITE attribute.

A typical BLOCKQUOTE is shown in Figures 6.7 and 6.8. Because BLOCKQUOTE usually introduces left-margin indentation, it is often used to indent blocks of text, such as the paragraphs following a heading. An example is shown in Figure 2.17 and 2.18. A much better approach is to use style sheets, as discussed in Chapter 7.

CENTER Element: Center the Enclosed Text

Usage: <CENTER> ... </CENTER>
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

CENTER center-aligns text enclosed within the element, including any enclosed blocks of text, with the exception of left- or right-aligned images or tables, or block elements for which the alignment is specified by the element’s own alignment attribute. In particular, CENTER is often used to center a TABLE. CENTER introduces a line break both before and after the centered text, so that only the enclosed text is centered. Note that CENTER does not introduce any extra vertical spacing beyond that of a regular line break.


NOTE: CENTER to Be Dropped from HTML

CENTER is to be dropped in a future version of HTML and should be avoided in new documents. Instead of CENTER, use

<DIV ALIGN="center"> ... </DIV>

which yields equivalent formatting.


Formally, CENTER is a block element, equivalent to a DIV. However, you must be careful about assuming that CENTER provides a line break, since browsers that do not understand this element will ignore the tags and will neither introduce a break, nor center the text.

CENTER (or DIV with ALIGN=“center”) can be used to center-align text between two HR elements, as in:

<center>
<hr width=80%>
These simple notes form a useful, single document
  explaining the rationale and organization of the Web Document
  template collection. Please print this out for off-line
  reference.
<hr width=80%>
</center>

If the browser does not support CENTER, the text will still be broken from the preceding or following material because of the HR. Figures 6.11 and 6.12 show how this differs from the following (which includes a P element):

<center>
<hr width=80%>
<P> These simple notes form a useful, single document
  explaining the rationale and organization of the Web Document
  template collection. Please print this out for off-line
  reference.
<hr width=80%>
</center>


Figure 6.11 HTML example document illustrating CENTER and HR elements.

<HTML>
<HEAD><TITLE>Example of CENTER and HR</TITLE></HEAD>
<BODY>
<H2>Example of CENTER and HR</H2>
It is always better to use <B>ALIGN</B>=“center” to align
things, but sometimes <B>CENTER</B> does have advantages.
For example, look at the following: text centered between
two <B>HR</B> elements:
<CENTER>
<HR WIDTH=“60%”>
This is a single-page document -- why not <BR>
  print it out for future reference?
<HR WIDTH=“60%”>
</CENTER>
<P>The <B>CENTER</B> element centers any enclosed, text,
including lists ...
<CENTER>
<UL>
  <LI>Lists
  <LI>Centering the text, and not the bullets
  <LI>Which is sometimes useful
  <LI>But not always.....
</UL>
</CENTER>
<HR NOSHADE>
Note that CENTER tags do not add extra vertical spacing. Observe
what happens when an extra <B>P</B> is added inside a <B>CENTER</B>:
<CENTER>
<HR WIDTH=“60%”>
<P>This is a single-page document -- why not <BR>
  print it out for future reference?
<HR WIDTH=“60%”>
</CENTER>
Note how the extra <B>&lt;P></B> in the second example of text
centred between HR elements  adds extra vertical space between
the text and the rule.
<HR SIZE=2 NOSHADE>
<DIV ALIGN=“right”>
<I>Another Exciting HTML Example</I>
</DIV>
</BODY> </HTML>


Figure 6.12  Rendering of the HTML document in Figure 6.11 by the Netscape Navigator 3 browser. Note the control of spacing around the HR 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.