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.


linking 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>


1 Answer

Rich Donnellan
Rich Donnellan
25,767 Points


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">


<!-- for HTML5 -->
<script src="scripts.js"></script>

Read more about it here.

ā€“ Rich

kimberly Liu
kimberly Liu
5,316 Points

...And if your js file is in another folder called js ("js/")...

<script src="js/scripts.js"></script>