HTML Script Tag

A script is a small piece of program that can add interactivity to your website. For example, a script could generate a pop-up alert box message, or provide a dropdown menu. This script could be Javascript or VBScript.

You can write your Event Handlers using any of the scripting language and then you can trigger those functions using HTML attributes.

External Script

If you have to use a single script functionality among many HTML pages then it is a good idea to keep that function in a single script file and then include this file in all the HTML pages. You can incluse a style sheet file into HTML document using <script> element. Below is an example.


<script src=”yourfile.js” type=”text/javascript” />


Internal Script

You can write your script code directly into your HTML document. Usually we keep script code in header of the document using <script> tag. otherwise there is no restriction and you can put your source code anywhere in the document. You can specify where to make a script run automatically(as soon as the page loads), or after he user has done something(like click on a link). Below is an example this would write a Hello Javascript! message as soon as the page loads:


<title> internal script></title>



<script type=”text/javascript”>

alert(“Hello Javascript!”)



This will produce following result :

Hello Javascript!