JavaScript Script Tag

by Monika Dadool 13-Jun-19

0 208


Script tag is used to tell the browser about beginning and ending points of a script inside an html document. JavaScript code can be placed inside the <body> and <head> sections of the html.

Example:

<script>
.
JavaScript code
.
.
</script>

Where, <script> is the point from where JavaScript code will starts </script> is the point from where JavaScript code will ends.
In the following example, a JavaScript's Script tag is created and its type attribute is set to text/JavaScript. In new browsers, there are no requirements of type, but in older documents, we have to set type attribute.

Suppose we want to write "hello students in js tutorial"

document.write and one string will be passed within a double quotes "hello students in js tutorial" when we open this script.html file in browsers, we will get output as hello students in js tutorial.

Example:

<script>
document.write("Welcome Students in JS Tutorial");
</script>

Output:
Welcome Students in JS Tutorial

<script language="javascript" type="text/javascript">
</script>


Script tag Attributes
Script tag can be incorporate with following attributes:

For Example:
language(this is deprecated)
* type(this is no longer required on new browsers)
* src(which is used URL specification of an external JS file)


Share:


Discount Coupons

SEMRush FREE Trial – PRO Account for 14 Days

FREE Pro Account worth $99.95 for 14 Days.



Comments

    No Comments Yet.

Leave a Reply