 <p>Since you have your javascript loading before your html, <code>document.getElementById("demo")</code> ends up being null, since the DOM hasn't loaded yet.</p> <p>Try moving that javascript to the bottom (I put it after the body tag, but not sure this is best practice). This way the DOM loads first, and then your javascript knows where to find the id of "demo".</p>