Versión en español



 


HTML script tag


Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

Table of contents


Description

The HTML script tag defines a script code. Scripts can be placed anywhere in the head or body of a document and be defined within the HTML script tag or in an external file.

If the "src" attribute is not present, the script code must be placed as content of the tag:

Code begin <script type="text/javascript">
function addtext()
{
document.write('This text has been added by a script.');
}
</script>Code end

When the "src" attribute is present, the script must be located in the resource defined by it, and the tag's content may be ignored.

Code begin <script type="text/javascript" src="addtext.js">
</script>Code end


Attributes

charset (charset)

Specifies the character encoding of the target URL. Refer to the type definition and the reference for character encoding for more information.

Example:

Code begin <a charset="utf-8" href="http://www.htmlquick.com">HTML code</a>Code end

src (uri)

Points to an external document containing the script or sripts.

type (content-type)

Specifies the scripting language as a content type (e.g., "text/javascript"). This attribute should be used instead of the deprecated "language" attribute.

language (cdata)

This attribute have been deprecated

Defines the scripting languages of the contents of this tag. It's been deprecated and authors should use the "type" attribute instead.

defer

When present this boolean attribute specifies that the script won't add or change content in the document (e.g., document.write in JavaScript). This allow user browsers to continue rendering the documnet.

Remember that boolean attributes must be defined as attr_name="attr_name" to be XHTML compliant.


Events

There are no events defined for this tag.

See complete list and information about events in HTML




Bypass footer options  |   Send to a friend Send to a friend  |  Post to del.icio.us Post to del.icio.us

Digg this page Digg this!  |  File on Furl File on Furl  |  Add to Yahoo! MyWeb Add to Yahoo! MyWeb

Bypass W3C declarations | 

Valid XHTML 1.0 Strict  |  Valid CSS Why should you trust us? Click the images on the left to see how seriously we write our own pages, then make your choice.

Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0. This website gives its best effort to achieve the Level Triple-A Conformance, W3C-WAI Web Content Accessibility Guidelines 1.0. If you find any detail or error that we didn't see, don't hesitate and let us know.

The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. -- Tim Berners-Lee, W3C Director and inventor of the World Wide Web.

 Link to us  |  Contact us  |  Beyond HTML  |  Tools and resources  |  Sitemap  |  Webmaster