Pr.Pg Next Pg

<SCRIPT></SCRIPT> tag tutorials

  • The <SCRIPT> tag is used to define a client-side script, such as a JavaScript.

  • The <SCRIPT> tag is supported in all major browsers.

  • The <SCRIPT> element either contains scripting statements, or it points to an external script file through the src attribute.

  • Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.

  • <SCRIPT> tag attributes are listed below:

 

Sr No

Attributes

Descriptions

1

ID

This attribute specify a unique id for an element in document.

2

style

This attribute specify an inline CSS style for an element.

3

title

This attribute specify extra information about an element.

4

draggable

This attribute specify whether an element is draggable or not.

5

hidden

This attribute specify that an element is not yet, or is no longer, relevant.

6

src

This attribute specify the URL of an external script file.

7

type

This attribute specify the MIME type of the script. examples of supported MIME types include text/javascript,text/ecmascript, application/javascript, and application/ecmascript. If this attribute is absent, the script is treated as JavaScript.

8

defer

This attribute specify that the script is executed when the page has finished parsing (only for external scripts).

9

charset

This attribute specify the character encoding used in an external script file

10

async

This attribute specify that the script is executed asynchronously (only for external scripts).

11

contextmenu

This attribute specify whether the content of an element is editable or not

12

spellcheck

This attribute specify whether the element is to have its spelling and grammar checked or not.

 

Syntax:

<head>

<script>.</script>

</head>

<body>

<script>.</script>

</body>

 

 

Example: HTML program to display string message using script elementHTML program to demonstrate span element

Output:
Example: HTML script program to display alert box

Output:
Example: HTML script program to show how to create simple javascript function

Output:
Pr.Pg border                                              Next Pg