HTML Scripts

HTML Scripts

Javascript is used by web developers to make web pages interactive and to enhance their functionality. The <script> tag which should be included in the head section of a document enables you to include javascript code in your document. You can also write the javascript code on a separate document and then call it using the src attribute.

This method is efficient in situations where you intend to use the same script for several documents on your website. Just like attaching external CSS files, this method save you time that you would otherwise have used to repeat the same task over and over.

Use the <nonscript> element to provide alternate content for users whose browsers do not support client-side scripting or those who have javascript disabled for security purposes. Note that the <nonscript> element can be used with all tags that are compatible with the <body> element.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Embedded JavaScript Example</title>        
</head>
<body>
    <script type="text/javascript">
        document.write("Hello World!");
    </script>
</body>
</html>