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 trialHerman Chenwi
Courses Plus Student 280 PointsHow do I add the opening and closing script tags <script></script>...? THIS IS SOLVED NOW. Thanks
I am working on the Javascript Basics subject on here But I can't seem to shake off the error message about adding a closing and opening script tags. Maybe I am putting it in the wrong location but can someone help me? Also when I tried to run the code without the script tags everything looked fine.
<!DOCTYPE HTML>
<html>
<script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<h1> JavaScript Basics</h1>
<body>
Hello this page belongs to Herman Chenwi. Welcome!
</body>
</script>
</html>
3 Answers
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsHi Herman!
The problem is that you have your closing script-tag outside of the closing body-tag, and the opening one before the head-tag.
They should preferable be together, like this:
<script></script>
And if you then have a script you want to write you can then write it inside of these tags, as the browser has been told that there's a script here. You could also link to a .js file by giving the opening script tag the attribute src="nameofthefile.js". Do you get it or did i confuse you even more?
You could place these script tags in the head of the document, or in the bottom of the body so that all earlier elements load before the script runs.
Herman Chenwi
Courses Plus Student 280 PointsI did thanks. As soon as submitted my query I found the answer I guess I should figure out a way to take it down. Thanks Jonas!
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsGlad you found a solution. Don't worry about taking it down, this way if someone else experience this problem they can find the solution here instead of having to ask themselves.