Chapter 2
Placing JavaScript in an HTML File
Key Skills & Concepts
    Using the HTML Script Tags
    Creating Your First Script
    Using External JavaScript Files
    Using JavaScript Comments
image
Now that you have been introduced to JavaScript, you’re ready to start coding. Since JavaScript code is run from HTML documents, you need to know how to tell browsers to run your scripts. The most common way to set off a script is to use the HTML <script> and </script> tags in your document. You can place your script tags in either the head or the body section of an HTML document.
This chapter first shows you how to use the script tags to begin and ...

Get JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.