Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDavid Moody
19,302 PointsI am putting a <script> tag inside the <body> tag, but the program is giving me an error.
Do I need to add "src=" to my <script> tags.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
<script></script>
</head>
<body>
<script>document.write("Hello")</script>
<script></script>
</body>
</html>
5 Answers
tylerpostuma2
5,175 PointsThe reason that it's giving you an error is because you missed a semi-colon at the end of your document.write() function. It should look like this: <script>document.write("Hello!");</script>
Hope this helped!
Stephen Urena
705 PointsI guess it depends on what the error says, but it looks like you capitalized "Content-type", should be like this
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
David Moody
19,302 PointsThe error is that it is testing to see if I am putting a <script> tag in the <body> section. It keeps saying that I am not inserting any <script> tags in the <body> section and won't let me pass that challenge in the class.
tylerpostuma2
5,175 PointsDid you try to put the semi-colon after the document.write? When I did that it let me pass through no issues.
Stephen Urena
705 PointsAhh ok, well for one you should delete the extra <script> tags in your head, and the empty one below...document.write()...so your code should look something like...
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body>
<script>
document.write("Welcome to my site");
</script>
</html>
tylerpostuma2
5,175 PointsI said that in my original answer...
Rohit Ukirde
10,453 Points<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script>document.write('Hello');</script>
</body>
</html>
This Works fine
Rohit Ukirde
10,453 PointsRohit Ukirde
10,453 PointsWhat's the error ?