|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
Figure 6.13 Example HTML document illustrating use of the DIV element. <HTML><HEAD><TITLE>Example of DIV</TITLE></HEAD> <BODY> <DIV ALIGN=left> <H1>A Left-Aligned Heading</H1> <P>A left-aligned paragraph....If you actually read this example you will realize that that the author is a raving idiot. ... more paragraph text ... </P> <DIV ALIGN=right> <H2>A right-aligned heading</H2> <BLOCKQUOTE> <P>A paragraph inside a block quotation -- the entire quotation is right-aligned. Note, however, that this is a formatting issue, and not a political statement on the part of the author.</P> </BLOCKQUOTE> </DIV> <P>Another left-aligned paragraph. Again, this is not a political statement.<BR> ... </P> </DIV> <HR NOSHADE> <DIV ALIGN=right> <I>Another Incredible HTML Example!</I> </DIV> </BODY></HTML>
A style sheet can specify the alignment, size, and width of an HR: Thus the attributes ALIGN, SIZE, and WIDTH are marked as deprecated and should be avoided when possible. P Element: Paragraphs
P marks a paragraph block: <P> marks the start of a paragraph and ends any previous paragraph. This is different from BR, which represents a simple line break, possibly within a paragraph. A paragraph should be thought of as a logical block of text, similar to BLOCKQUOTE, ADDRESS, or Hn heading, whereas a BR is simply a character that causes a line break. Typically, a paragraph is rendered with extra vertical space separating it from the previous and subsequent blocks of text. In some cases, the first line is indented. For historical reasons, an end tag </P> is not required. Instead, the end of a paragraph is implied by the start of another paragraph or by the start of another element marking a block of text. However, an end tag definitively marks the paragraph end, and this is the recommended form. P 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. P can also take the optional ALIGN attribute to specify text alignment. The allowed values are center, left, right, or justify, which call for the indicated text alignment within the paragraph. Note that the justify alignment option (to justify the text between the left and right margins) is not widely supported. HTML 4 recommends using a style sheet to specify text alignment within P elements. Creating Extra Vertical SpacingIf you wish to leave extra vertical space, you should use a paragraph containing multiple <BR> tagsfor example: ... text <P> <BR><BR><BR> <H2>Heading, with lots of space above it</H2> You should not use empty paragraphs to add vertical spacing, as in: ....text <P><P><P> <H2> And another thing of Interest </H2>
Formally, a paragraph cannot be empty, so this is illegal. Most browsers will tolerate this, but their interpretations will varysome will leave extra spaces, while most (Internet Explorer 3/4 and Netscape Navigator 3/4) ignore the extra <P> tags completely. The latter is formally the recommended behavior. PRE Element: Preformatted Text
|
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. |