HTML: The Markup Language

scriptembedded script # T

The script element enables dynamic script and data blocks to be included in documents.

Permitted content #

Permitted attributes #

Descriptions for attributes specific to this element #

type = MIME type
The language of the script or format of the data.
The language attribute on the script element is obsolete. You can safely omit it.
language = string OBSOLETE
Specifies that the language of the script is JavaScript.
src = URI
The address of the external script to use.
defer = "defer" or "" (empty string) or empty
Specifies that script should be executed after the document has been parsed.
async = "async" or "" (empty string) or empty NEW
Specifies that the script should be executed asynchronously, as soon as it becomes available.
charset = character encoding name
The character encoding of the external script.

Additional constraints and admonitions #

Tag omission #

A script element must have both a start tag and an end tag.

Permitted parent elements #

any element that can contain metadata elements, any element that can contain phrasing elements

DOM interface #

interface HTMLScriptElement : HTMLElement {
           attribute DOMString src;
           attribute boolean async;
           attribute boolean defer;
           attribute DOMString type;
           attribute DOMString charset;
           attribute DOMString text;

Typical default display properties #

script {
display: none; }