The recommendation for HTML expresses it as an application of SGML, which requires that the DOCTYPE
declaration appear before the HTML element (ignoring HTML comments). Even without the DOCTYPE
, adding a SCRIPT
element outside the HTML
element (either before it or after it) is not valid HTML. Of course, HTML validity may not be a requirement for you, so long as it works in most browsers, and then the quirks-mode switching mentioned will get you: without the DOCTYPE
, many browsers will switch to quirks mode, possibly changing the layout.
I assume the TAM script fragment is being added by some proxy or other which is not able to properly analyse the HTML structure of the page and insert the SCRIPT
in the correct position in the HEAD
or BODY
of the document. In this case, adding to the end of the document, while not valid HTML, will work in most web browsers.