SCRIPT Description:
The SCRIPT element inserts scripts into web pages. You can use this tag any number of times within the HEAD or the BODY of your HTML document.
External scripts are written as separate documents and then associated in the document with the src attribute. If there is no src attribute, the user-agent interprets the contents of the SCRIPT element as the script.
SCRIPT Web Browser Support:
- Android 1+
- AvantGo Palm OS
- AvantGo Windows CE
- Chrome 1+
- Firefox 1+
- Internet Explorer 4+
- iOS (iPhone/iPad/iPod) 1+
- Netscape 3+
- Opera 3+
- Safari 1+
- WebTV/MSN TV
HTML Versions
SCRIPT Attributes:
SCRIPT End Tag:
</script> REQUIRED
Contents:
An embedded script. The following tags are valid within the SCRIPT element:
<!-- comment -->
Note: A SCRIPT must not contain <!-- without the closing -->.
SCRIPT Valid Context:
The SCRIPT tag is valid within the following tags:
BLOCKQUOTE,
BODY,
BUTTON,
CENTER,
DD,
DIV,
DT,
FIELDSET,
FORM,
HEAD,
IFRAME,
LI,
NOFRAMES,
OBJECT,
P,
TD,
TH
SCRIPT Usage:
Simple script inline on the page
<script>
alert("This is a script.");
</script>
External script
<script src="myscript.js"></script>
Script with NOSCRIPT Alternative
<script>
alert("This is a script.");
</script>
<noscript>
<p>
This is a script, but you are seeing the no-script content.
</p>
</noscript>
SCRIPT Special Notes:
- While using comment tags inside a
SCRIPTelement is valid, this can cause problems with some CMS systems, and since most browsers recognize theSCRIPTelement, it's better to leave them out. - The
languageattribute is obsolete in HTML5. You should use thetypeattribute instead. - If you are writing ECMAScript (JavaScript) inside the
SCRIPTelement, thetypeattribute is not required. - JavaScript, ActionScript, and VBScript are the most common languages for scripts on the web, but you can use any type of scripting language you would like, you just need to specify the correct MIME type in the
typeattribute. - I strongly recommend using the
NOSCRIPTelement whenever you use a script on your web pages to keep your pages accessible. This is what displays if the script doesn't work or if the browser has scripting disabled.

