<script> element within the
document.write commands generate output that is added to the
<body> element of the page when the script executes. The content that you generate becomes part of the HTML code of the page, so you can add HTML elements in there if you want (ideally you’d avoid creating elements dynamically whenever possible, however).
Writing compliant makrup maximizes the chances that your pages will work fine with most existing and future web browsers. A useful article about following web standards can be found at http://www.w3.org/QA/2002/04/Web-Quality. A good article explaining the document type declaration (
The debate on standards seems to be an endless one, with one group of people being very passionate about strictly following the standards, while others are just interested in their pages looking good on a certain set of browsers. At the moment of writing, The examples in this book contain valid HTML code, with the exception of a few cases where we broke the rules a little bit in order to make the code easier to understand. A real fact is that very few online websites follow the standards, for various reasons.