HTML script tag
Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.
The
HTML script tag defines a script code. Scripts can be placed anywhere in the head or body of a document and be defined within the HTML script tag or in an external file.
If the "src" attribute is not present, the script code must be placed as content of the tag:
Code begin
<script type="text/javascript">
function addtext()
{
document.write('This text has been added by a script.');
}
</script>Code end
When the "src" attribute is present, the script must be located in the resource defined by it, and the tag's content may be ignored.
Code begin
<script type="text/javascript" src="addtext.js">
</script>Code end
Specifies the character encoding of the target
URL. Refer to the type definition and the reference for
character encoding for more information.
Example:
Code begin
<a charset="utf-8" href="http://www.htmlquick.com">HTML code</a>Code end
Points to an external document containing the script or sripts.
Specifies the scripting language as a content type (e.g., "text/javascript"). This attribute should be used instead of the deprecated "language" attribute.
language (cdata)
Defines the scripting languages of the contents of this tag. It's been deprecated and authors should use the "type" attribute instead.
defer
When present this boolean attribute specifies that the script won't add or change content in the document (e.g., document.write in JavaScript). This allow user browsers to continue rendering the documnet.
Remember that boolean attributes must be defined as attr_name="attr_name" to be
XHTML compliant.
There are no events defined for this tag.
See complete list and information about
events in HTML