You are here: Reference > HTML > tags > script

script element

Browser support:
Specifies a script block within a HTML document.
The script element allows authors to write or include script codes into HTML documents.
Use the type attribute to specify the language for a script block. If the type attribute is not specified (it was only required in older browsers), JavaScript (JScript) is the basic interpreter for the code.
The script tag should be placed in the head or in the body element.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: script.

Possible members:

Sets the character encoding of the document, a linked document or a script block.
Sets whether the script is going to generate any document content.
Sets an event that the script element should listen for.
Sets the identifier of the element to which the script is bound when a specific event is fired for the element.
Sets a unique identifier for the object.
Specifies the language of the element.
Sets the scripting language for the current element. Use it only for the script element.
Sets the name of an element.
Sets the location of a file containing scripting code.
Sets the type of scripting language to use.

Example HTML code 1:

This example illustrates the use of the script element:
    <script type="text/javascript">
        window.onload = alert ("Fires onload event.");
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to link a .js (JavaScript) file into a HTML document:
    <script type="text/javascript" src="sample.js"></script>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content