Why is document.body null in my javascript?
<p>Here is my brief HTML document. Why is Chrome Console noting this error: "Uncaught TypeError: Cannot call method 'appendChild' of null"?</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Javascript Tests&lt;/title&gt;

    &lt;script type="text/javascript"&gt;

        var mySpan = document.createElement("span");
        mySpan.innerHTML = "This is my span!";

        mySpan.style.color = "red";
        document.body.appendChild(mySpan);

        alert("Why does the span change after this alert? Not before?");

    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
