Locked lesson.
About this lesson
Where does JavaScript go? Putting JavaScript tags in the HTML head, vs body, vs external files.
Exercise files
Download this lesson’s related exercise files.
Where to Use JavaScript.docx59.1 KB Where To Use Javascript - Solution.docx
59.2 KB
Quick reference
Where to Use JavaScript
There are several ways to use JavaScript on a web page.
When to use
Anytime you want to use JavaScript on a web page, you'll use one of these methods.
Instructions
You can use JavaScript by simply writing it on a web page inside an opening <script> and closing </script> tag.
You can also reference an external JavaScript file using a <script src="nameofFile.js"></script> tag (where nameofFile.js is the name of your external JavaScript file).
You can also use JavaScript by writing snippets of it into certain HTML elements (like links and buttons).
Hints & tips
- You can write JavaScript directly onto a web page inside <script> tags
- You can reference JavaScript externally with a <script src="nameofFile.js"></script> tag.
- You can also use snippets of Javascript in certain HTML elements.
Lesson notes are only available for subscribers.