Because HTML is fairly freely formatted, you have to explicitly tell it when a line break is to appear. You can do this a variety of block level tags. Its most likely done with a <BR> or <P> tag.
When you use the document.write() method, you need to explicitly include the necessary <BR> or <P> tags otherwise the HTML output that gets displayed will all run onto a single line. Placing a \n newline escape into the output may make the HTML source look nice but it won't affect the displayed output.
A line break is also introduced when you use block structured elements in the HTML. Here is a list of common HTML tags that do this (there are others too):
<BLOCKQUOTE>
<BODY>
<BR>
<DD>
<DL>
<DIV>
<DT>
<H1> etc
<HR>
<HTML>
<LI>
<OBJECT>
<OL>
<P>
<PRE>
<UL>
See also: | Pitfalls |
Prev | Home | Next |
Newline | Up | News posts containing JavaScript |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |