LERAN HTML COMPLETE

Learn one of the most powerful programming languages in the world and become a rockstar developer.

HTML Scripts


HTML Script

The script element is used to embed or reference JavaScript within an HTML document to add interactivity or affect the behavior of web pages.

Adding a Script to HTML Document

The <script> element is used to define a client-side script.

The script in the example below writes Hello World! to the HTML output:

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

Calling External Script

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>External JavaScript Example</title>
    </head>

<body> <script src="hello.js"></script> </body> </html>


x
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Privacy Policy That's Fine