web programming 3.4
<script>
tag allows a web page to include interactive content, which the browser assumes to be JavaScript unless indicated otherwise. The optional type attribute is used to indicate the content type when the content is not JavaScript. The src attribute provides the URL of an external document containing the interactive content. If a <script> tag does not have the src attribute, then the interactive content is contained directly within the tag. The HTML below shows two ways the <script> tag can be used.
<style>
tag allows the web page to introduce presentational directives, usually CSS. A <style> tag is placed in an HTML document prior to the <body> tag, because the style section is designed to describe the presentation of the entire document.
common error
to forget the closing </script> tag when using the src attribute. Even when the interactive content is located in a separate external document, the closing </script> tag must be included.
Good practice
to use the src attribute to separate content and functionality and promote modularity. An external JavaScript file can be edited separately from an HTML file, which allows a web page's interactive content to be updated even if the content is unchanged. A separate JavaScript file can also be reused on many web pages to provide the same functionality for different pieces of content. Additionally, when the JavaScript file is separate, a browser that doesn't understand JavaScript, such as a screenreader for blind users, can avoid downloading the JavaScript file that will not be used.