Html - script, noscript Tag

How to add javascript to Html?


JavaScript is used in HTML pages for a number of reasons such as image manipulation, form validation, and dynamic changes of content, user interaction and more. Any number of javascript can be placed in a HTML document. The javascript is placed in HTML document by adding it inside the tag <script>.
The HTML <script> Tag:

<script> </script>
The javascript used in HTML pages is also called as a client-side script. You could add the javascript inside the <script> element or you could also point to an external script file through the src attribute.
Example :
document.write("Welcome World!");

Result :

In the above example, the document.write() document refers to the current html document page and write method will write the text given inside the () braces. Here, it will write "Welcome World!!" inside the current document.
The HTML <noscript> Tag:

<noscript> </noscript>

The <noscript> tag is used to provide an alternate content for users who have disabled scripts in their browser or for users having browsers that doesn't support client-side scripting. The <noscript> element can contain all the elements that you can find inside the element of a normal HTML page. The content inside the <noscript> element will only be displayed if scripts are not supported, or disabled in the user's browser.
Example :
<script>document.write("Welcome World!");</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>

Result :

Ask Questions

Ask Question