JavaScript: Script Tag

light111How to use <script> tag

There are different way available how the script tag can be used in the HTML file.

The SCRIPT tag usually added to the header section of the HTML file. 

One way is added the script elements in the script tag or else create a javascript file( .JS) that contains all the elements and add this script file into the  HTML file in the script tag.

The below screen shots are taken from Visual Studio.

The typical HTML file structure.


Take the path of the HTML file and put in the address bar of the Chrome/IE.  The output is shown as below:


The <SCRIPT> tag can be added to the HEADER section of the HTML file.


Here “document” is the object. When a HTML document is loaded into the window it becomes a document object that contains the content of the page. 




Another way is to create a .JS file and write JavaScript code inside it.


Add the PATH of the external .JS file in the Script tag of the HTML file.


Execute and check O/P-


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s