If you use the DOM commands to create and add the extra content then the script will update the DOM directly and the DOM will ensure that it generates valid HTML. At least that will be true provided that you only ever ask it to generate valid DOM elements and attributes.
At least using the DOM commands will guarantee that a strict page will still remain in standards mode even if you do add invalid tags or attributes.
It is only if you use innerHTML or document.write that you can directly write to the HTML and potentially write something invalid where the browser will have to interpret what you meant and potentially put the page into quirks mode.
Helping others to solve their computer problem at http://www.felgall.com/