HTML JavaScript

HTML JavaScript

The JAVA is a tool that has revolutionized the internet. Java programs that are embedded within HTML documents can produce dynamic graphics and animations. Java is an object oriented programming language. JavaScript and frameworks are used in web development by various developers.

The script element

The script element includes a program script. It is used as follows:

<script> … … … </script>

The script element can contain the script program code. And this element can be written or declared inside the HEAD element. The script element uses the attributes LANGUAGE and SRC. To include program script in an HTML document, the script element is used.

We can include the scripts in two different ways:

  1. As the content of script element
  2. Externally via SRC attribute (It references the URL of the script)

If the program script is embedded with the script element then we must use the end tag </script>.

If we use the second method that is if we include the script externally via SRC attribute then the ending tag </script> is not mandatory rather it should be absent.

The attribute LANGUAGE used in a script element specifies the language of the script and it is very important. The LANGUAGE attribute is assigned the value “LiveScript” that refers to the scripting language.

In HTML document when embedding a script may cause problems. For example using </x in this tag the element x is an ASCII letter, this will cause the termination of the element prematurely.

Suppose we want to count apples in a basket, we can do this using a loop in the script tag body but this will not be shown in the display window or the browser.



<h1>Counting Apples in the basket</h1>


for(var n=1;n<=3; n++) {

alert(“Apples”+n+” in the basket!”)



<h1>Apples counted</h1>