Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Introducing JavaScript Write Another Program

Fidel Zv
Fidel Zv
1,625 Points

I don't know how I am supposed to add an opening and closing script tag inside the body of the page. I'm a bit confused

This is what I did and it keeps telling me syntax error but have no clue how to fix it

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
  <script>
  alert("Here's another message from Treehouse");
  <script>
</head>
<body>
  <div class="container">
  <h1>where to place your Javascript code.</h1>
  </div>
  <script src="scripts.js"></script>
</body>
</html>

3 Answers

Hey Fidel,

You are going to want to put your <script> tags inside of the <body> tags make sure the closing </script> tag is within the nest of the closing </body> tag. For this challenge you are doing inline scripting and don't need a link to your external javascript page.

It would look like this.

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
  <h1>where to place your Javascript code.</h1>
  <script>
      alert("Warning!");
  </script>
</body>
</html>

Between <body> and </body>

<script> alert('Warning!'); </script>

Fidel Zv
Fidel Zv
1,625 Points

Thanks a lot Dylan