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 trialMatt Bloomer
10,608 Pointslinking javascript file
I am having trouble linking the js page to to the html. The js page is named scripts.js. What am I doing wrong? Here is the code: <!DOCTYPE html> <html> <head>
<meta charset="utf-8">
<title>Matt Bloomer| Designer</title> <link rel="stylesheet" href="css/style.css"> <script src="scripts.js"></script>
</head>
1 Answer
Rich Donnellan
Treehouse Moderator 27,708 PointsMatt,
In a nutshell, the script
tag(s) should be placed in either the head
or before the closing body
tag using the following syntax:
<!-- for HTML4 and (x)HTML -->
<script type="text/javascript" src="scripts.js">
or
<!-- for HTML5 -->
<script src="scripts.js"></script>
Read more about it here.
ā Rich
kimberly Liu
5,316 Pointskimberly Liu
5,316 Points...And if your js file is in another folder called js ("js/")...
<script src="js/scripts.js"></script>