The cover of The Complete Idiot's Guide to Create a Web Page The Complete Idiot's HTML Tag Reference

| Index | Previous Tag: <SAMP> | Next Tag: <SELECT> |


<SCRIPT>

Inserts a script into the page.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later 3.0 and later 2.0 and later
Notes:
  • This tag requires the </SCRIPT> end tag.
  • To hide a script from browsers that don't support this tag, place comment tags between the <SCRIPT> and </SCRIPT> tags.
  • If the script writes text to the page, insert the <SCRIPT> tag at the spot where you want the text to appear.
  • For all other scripts, insert the <SCRIPT> tag between the </HEAD> tag and the <BODY> tag.
Attributes:
CHARSET = "Text"
The character set used by the script.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later Not supported Not supported

Notes:

CLASS = "Text"
The style sheet class used by the tag.

Support:

HTML StandardInternet ExplorerNetscape Navigator
Not supported 4.0 and later Not supported

Notes:

  • You can specify two or more classes; be sure to separate each class name with a space.

DEFER
Tells the browser that the script will not write text or tags to the page using document.write.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later 4.0 and later Not supported

Notes:

  • Adding this standalone attribute should mean that your page loads faster because the browser doesn't hae to examine the script for potential document content. Therefore, it can defer running the script until the page is rendered.

EVENT = "Text"
The event that will cause the script to run.

Support:

HTML StandardInternet ExplorerNetscape Navigator
Not supported 4.0 and later Not supported

FOR = "Text"
The form control that the script is associated with.

Support:

HTML StandardInternet ExplorerNetscape Navigator
Not supported 4.0 and later Not supported

Notes:

  • To use this attribute, you must add an ID attribute to the associated form control, and then set FOR equal to that ID value.

ID = "Text"
An alphanumeric string that uniquely identifies the tag.

Support:

HTML StandardInternet ExplorerNetscape Navigator
Not supported 4.0 and later Not supported

Notes:

  • Although you can use letters and numbers for the ID, the first character must be a letter.

LANGUAGE = "Text"
The programming language used by the script.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later 3.0 and later 2.0 and later

Notes:

SRC = "Text"
The URL or filename of an external file that contains the script code.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later 3.0 and later 3.0 and later

Notes:

  • Use either just a file name (if the script file is in the same directory as the page), a relative name (if the script file is in another directory), or a full URL.

TYPE = "Text" (Required)
The content type of the script.

Support:

HTML StandardInternet ExplorerNetscape Navigator
4.0 and later 4.0 and later Not supported

Notes:

  • Use either "text/javascript" or "text/vbscript".
  • TYPE is preferred over LANGUAGE in HTML 4.0.

Example:
<SCRIPT>
<!--
document.write("Welcome to the <B><SCRIPT> Doctor</B>")
//-->
</SCRIPT>
How It Looks:

| Index | Previous Tag: <SAMP> | Next Tag: <SELECT> |