Horje
How to include JavaScript File in HTML5 ?

In HTML5, we can include external scripts using the <script> element. External scripts are commonly used to link JavaScript files or other script files hosted externally. Here’s how you can include external scripts in HTML5.

Link the External Script in HTML

To link an external script in HTML, use the <script> tag with the src attribute pointing to the external JavaScript file.

Syntax

<body>
    <h1>My Web Page</h1>

    <!-- External JavaScript -->
    <script src="script.js"></script>
</body>

Link the Internal Script in HTML

To include an internal (inline) script directly within the HTML document, use the <script> tag without the src attribute

Syntax

<script>

// Your JavaScript code goes here
console.log("Hello, World!");
</script>



Reffered: https://www.geeksforgeeks.org


HTML

Related
HTML Table Headers HTML Table Headers
HTML Table Styling HTML Table Styling
Explain the purpose of DOCTYPE in HTML Explain the purpose of DOCTYPE in HTML
Difference between GET and POST Methods in HTML Form Difference between GET and POST Methods in HTML Form
How to use the target attribute in the &lt;a&gt; Tag in HTML ? How to use the target attribute in the &lt;a&gt; Tag in HTML ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
15