Martin Rinehart said:
PE, I already know your manners are atrocious. That's not news.
Awww, come on! If you tell people they are wrong, and at the same time
tell them what is right, they might actually feel smarter afterwards
instead of feeling inferior. How would that make you feel better then?
What would be helpful is to know why document.body is correct and
document is not. Even more helpful would be an explanation of the
consequences of using the wrong one; the benefits of using the right
one.
The problem with appending HTML elements to "document", is that the
resulting DOM structure is not a valid HTML document.
In HTML, elements should go into either head or body, with visible
content in the body. That is what you achieve by adding children to
the body element. (And yes, script elements not inside either head
or body is also invalid HTML, even though it's pretty common.)
If you add elements as children of the document element, i.e., the
equvialent of adding them directly inside the <html> element in
HTML syntax, some browsers will likely do error-correction and
"make it work" anyway. However, there is no standard specifying
how it should work. Will styles put on the body element be
inherited? Will body.onclick be triggered by clicking on your
element? It's likely to blow up in your face at the most unfortunate
moment.
/L '
'