How do you include JavaScript in an HTML document?

Prepare for the CIW Site Development Associate Exam. Utilize various questions and receive explanations to ensure readiness. Boost your confidence and knowledge for success!

Multiple Choice

How do you include JavaScript in an HTML document?

Explanation:
Including JavaScript in an HTML document is typically done using the <script> tag. This tag allows you to embed JavaScript code directly in the HTML file or link to an external JavaScript file. The <script> tag can be placed in the <head> section of the document for scripts that need to be loaded before the content is displayed, or in the <body> section for scripts that manipulate content after it has loaded. When JavaScript is included using the <script> tag, you can write the code directly between the opening and closing <script> tags, or you can reference an external source by including the "src" attribute with the URL of the JavaScript file. This flexibility makes the <script> tag the standard method for adding JavaScript functionality in web pages. Other choices do not serve the purpose of including JavaScript effectively. The <link> tag is primarily used for linking to external stylesheets, while the <style> tag is meant for embedding CSS styles. Although you can technically write JavaScript directly in the body of an HTML document, it must still be wrapped in the <script> tags to be recognized as JavaScript code by the web browser.

Including JavaScript in an HTML document is typically done using the