twoon
twoon

Reputation: 1

Title element won't display after adding javascript, but works when I remove it

So I know this is a super noob question but after adding a script tag for a .js file,my title element stops working.

As an example :

<html>
<title>TEST</title>
<head> 
 <script type="text/javascript" src="datetime.js"></script>
</head> 
 <body onload="showDateTime()"> 
    <p> 
    </p>
  </body>
  </script>
</html>

yet if I delete the "<script type="text/javascript" src="datetime.js"></script>" portion, the title element works again. ANy help would be appreciated. Thanks

Upvotes: 0

Views: 199

Answers (2)

izilotti
izilotti

Reputation: 4937

Two problems:

  • The title tag must be placed inside the <head></head>
  • The <script> tag is incorrectly nested. It must be closed in the head

    <html>
      <head> 
        <title>TEST</title>
        <script type="text/javascript" src="datetime.js"></script>
      </head> 
      <body onload="showDateTime()"> 
        <p id='datetime-container'> 
       </p>
      </body>
    </html>
    

The code above should work.

Upvotes: 1

TheFrozenOne
TheFrozenOne

Reputation: 1715

The title tag needs to be inside the head.

http://www.w3schools.com/html/html_head.asp

Upvotes: 0

Related Questions