HTML element: <script>
The <script> element defines a script, such as a JavaScript®. The script may be enclosed within the element, or may reference an external script.
Differences between HTML, XHTML, and XHTML-MP
The language attribute is deprecated in HTML 4.01. XHTML (strict) does not support the language attribute.
XHTML-MP does not support the <script> element.
Attributes
Attribute |
Value(s) |
Description |
Supported in |
|---|---|---|---|
charset |
charset |
This attribute specifies the character encoding used in the script. |
4.6 or later |
defer |
— |
When specified, this attribute indicates that the script does not generate any document content. |
4.6 or later |
language |
script_language |
Deprecated. This attribute specifies the scripting language. |
4.6 or later |
src |
URL |
This attribute specifies the URI where an external script document is located. |
4.6 or later |
type |
text/emcascript text/javascript application/ecmascript application/javascript |
Required. This attribute specifies the MIME type of the script. |
4.6 or later |