Add JavaScript to HTMLThere are following three ways through which we can add the JavaScript code into the HTML document:
Include the JavaScript Code in tag.In this section, you will learn to include the JavaScript code between the and tag.Syntax In the above syntax, the JavaScript code written between the tag is put between the and tag in HTML file.Example Output: 2. i) Include the JavaScript code in the tag.In this section, you will learn about how to include the JavaScript code in-between the and tag.Syntax In the above syntax, the JavaScript code written between the tag is put in-between of the and tag in HTML file.Example Output: ii) Include the JavaScript code after the tag.In this section, you will learn to include the JavaScript code after the tag.Syntax In the above syntax, the JavaScript code written between the tag is put after the … tag in HTML file.Example Output: Link the Separate file of JavaScript in HTMLIn this section, you will learn to include the file of JavaScript code in the HTML file. Syntax |
Output: