tutorialstonight logo
A Platform To Learn To Code

HTML JAVASCRIPT



Javascript is a scripting language that makes HTML pages dynamic and more interactive.

There are two ways by which javascript programs can be added to the HTML webpage :

  • internal javascript
  • External javascript


HTML script tag

The script tag is used either to give a source to an external javascript file or is used for writing a javascript program within the HTML document.

When we have javascript program written in another file then we link it with HTML file using src attribute as shown below:

<script src="external-javascript.js"></script>

We can also write javascript programs within the HTML document using script tag either inside the head section or in the body section.

Example

Run the code

use of javascript

Javascript can perform various tasks on the webpage like it can change or modify content of any element, can change size of container, can change color of text and many more.

Here we are going to see few usage of javascript.

Changing element content using javascript:

Example

Run the code

Changing box sizing using javascript:

Example

Run the code

Changing color, font-size, background-color etc using javascript.

Example

Run the code

The noscript tag

The noscript tag is used to display the message it contains in case your browser does not support javascript.

Example

Run the code