XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / script
(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
script
HTML 4.01 | HTML 5 |
<script> ... </script>
Places a script in the document, usually JavaScript in web documents. This element can appear any number of times in the head or body section of the document. The script itself can be inside the script element or in an external file specified by the src attribute.
Notes
If the script is supplied as the content of the script element, XHTML requires it to be enclosed in a special CDATA section, as shown in the example below.
Start/end tag
Required/required
Attributes
async(async="async"in XHTML 5)HTML 5 only. Specifies that the script should run asynchronously as soon as it is available.
charset="Zeichenkodierung"Specifies the character encoding of an external script. This does not affect the content of the
scriptelement.defer(defer="defer"in XHTML)Specifies that the script should run only after the page has finished loading.
id="Text"XHTML and HTML 5. Gives the element a unique name.
language="Text"Deprecated. Specifies the scripting language’s name. This attribute was not standardized and is deprecated in favor of the attribute
type.src="URL"The location of the external script.
type="Inhaltstyp"Required in HTML 4.01. Optional in HTML 5 when JavaScript is used. Specifies the language of the current script. This setting takes precedence over general script settings for the document. The value is a content type, usually
text/javascript.xml:space="preserve"XHTML only. Instructs XML processors to preserve whitespace within the element.
Example (HTML 4.01 and HTML 5)
<script type="text/javascript">
... (Hier steht der JavaScript-Code) ...
</script>Example (XHTML 1.0 and HTML 5 in XML syntax)
<script>
// <![CDATA[
... (Hier steht der JavaScript-Code) ...
// ]]>
</script>
|
Copyright © 2010 O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "HTML & XHTML ─ kurz & gut" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de