CONNECT JAVASCRIPT TO YOUR HTML DOCUMENT

Introduction

Javascript is a versatile programming language that enables interactive features and dynamic content on web pages. To utilize its power in a webpage, it must be properly connected to the HTML document. This connection forms the foundation for enabling several javascript functionalities such as form validation, dynamic updates, animations, and user interaction without reloading the page. Understanding how to integrate JavaScript into HTML is essential for any web developer.

Definition of terms

  • Javascript (JS): A scripting language used to create and control dynamic content on websites.
  • HTML (HyperText Markup Language): The standard markup language used to structure content on the web.
  • Script Tag (<script>): An HTML tag used to embed or reference Javascript code within an HTML document.
  • External Javascript File: A separate (.js) file that contains Javascript code, which is linked to an HTML file for better organization and reusability.

For further study:

  1. Digital ocean: https://www.digitalocean.com/community/tutorials/how-to-add-javascript-to-html
  2. W3schools: https://www.w3schools.com/tags/att_script_src.asp

How to connect javascript to your HTML document

  1. Inline javascript: it is written within the HTML elements.
CONNECT JAVASCRIPT
  1. Internal javascript: to connect javascript in this case, javascript is written between the script tag (paired tag) that is between the head tag (paired tag).
  1. HTML file: it is written outside the HTML document. The document saved with the extention of a javascript document (.js). It is connected through the code <script src=””> </script>

HTML document

Javascript document

Leave a Comment

Your email address will not be published. Required fields are marked *