Problem with Javascript and HTML Document.createElement() Function

So basically I have this problem going on where every time I do

let paragraph = document.createElement('p')
paragraph.textContent = 'paragraph example'
Document.body.appendChild(paragraph)

It would not create the element on my webpage. This is happening to all my HTML tags.

CSS:

paragraph {
  color: rgb(255, 140, 0);
  font-size: 32px;
  margin: 0;
  padding: 0 0 16px 0;
  font-weight: 600;
}


HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Hello!</title>
    
    <!-- import the webpage's stylesheet -->
    <link rel="stylesheet" href="/style.css">
    
    <!-- import the webpage's javascript file -->
    <script src="/script.js" defer></script>
    </head>  
  <body>
    <h1></h1>
    
    <p>

    </p>

    <!-- include the Glitch button to show what the webpage is about and
          to make it easier for folks to view source and remix -->
    <div class="glitchButton" style="position:fixed;top:20px;right:20px;"></div>
    <script src="https://button.glitch.me/button.js" defer></script>
  </body>
</html>

Javascript:

let paragraph = document.createElement('p')
paragraph.textContent = 'paragraph example'
Document.body.appendChild(paragraph)

That needs to be lower case document to get the actual document object.

Thanks, it worked out fine :smiley:

1 Like