HTML and CSS Reference
type This attribute should be set to the MIME type corresponding to the scripting language
language attribute is more commonly used, but the type attribute is standard. When not
consistent it is dangerous to use. Also, it is possible to indicate version information in the
xml:space This attribute is included from XHTML 1.0 and is used to set whether spaces
need to be preserved within the script element or the default whitespace handling should
be employed. In practice, this attribute is not often used by developers.
alert("Hello World !!!");
<!-- code in external file -->
HTML 4, 4.01, 5
XHTML 1.0, 1.1
Firefox 1+, Internet Explorer 3+,
Netscape 2+, Opera 4+, Safari 1+
• It is common practice to comment out statements enclosed by a <script> tag.
Without commenting, script code can be displayed as page content by user agents
that do not support scripting. The particular comment style might be dependent on
In VBScript, use
VBScript code here
XML escapes using CDATA sections are also possible; however, in all cases it is better
to avoid intermixing script code in a markup document and instead to link to it.
• The HTML 3.2 specification defined a placeholder script element.
• The event and for attributes are defined under transitional versions of HTML 4.01
but only as reserved values. Later specifications appear to have dropped potential
support for them, though they continue to be supported by Internet Explorer.