HTML JavaScript

As HTML and CSS gives structure and styling to the page.

In HTML JavaScript is used to make the webpage interactive and dynamic. It is basically a text based programing language which make the webpage responsive and interactive.

HTML JavaScript Tags

Following are HTML tags used for client side javascript:

<script>It defines the client side javascript
<noscript>it shows alternative text incase script is not working..

Lets see a simple example of HTML JavaScript without using any tag.


<button type="button"
onclick="document.getElementById('date').innerHTML = Date()">
Date and Time.</button>

<p id="date"></p>
HTML JavaScript

HTML Script Tag

HTML Script tag is used to define client side script. Either the script statement is written in script tag or an external file is linked in this tag through src attribute.

There are several methods to select the html element but most commonly used method is document.getElementById().

JS Common uses:

  • Form Validation
  • Image/text Manipulation
document.getElementById("text").innerHTML = "Hello World";

There are much more changings which can be done using JavaScript.

HTML <noscript> Tag

The HTML <noscript> tag is used to show an alternative text incase script tag is not working because some browsers do not support java script .

<noscript> Sorry, This txt will be shown when any browser will not support Java Script! </noscript>

Note: The output of this code is same like above one because browser is supporting JavaScript but its better to write <noscript> tag on safe side so that if any browser do not support java script than this text will be shown.