1. Computing & Technology

Discuss in my forum

<script></script>

By , About.com Guide

SCRIPT Description:

The SCRIPT tag inserts scripts into web pages. You can use this tag any number of times within the HEAD or the BODY of your HTML document.

External scripts are written as separate documents and then associated in the document with the src attribute. If there is no src attribute, the user-agent interprets the contents of the SCRIPT tag as the script.

If you are not using an external script, it’s a good idea to enclose the SCRIPT tag contents with comment tags (<!-- -->) so that browsers don’t mis-interpret the code and display the script data by mistake.

SCRIPT Web Browser Support:

HTML Versions

SCRIPT Attributes:

SCRIPT End Tag:

</script> REQUIRED

Contents:

An in-line script. The following tags are valid within the SCRIPT tag:
<!-- comment -->

SCRIPT Valid Context:

The SCRIPT tag is valid within the following tags:
blockquote, body, button, center, dd, div, dt, fieldset, form, head, iframe, li, noframes, object, p, td, th

SCRIPT Usage:

Simple script inline on the page

<script language="javascript" type="text/javascript">
  <!--
  alert("This is a script.");
  -->
</script>

External script

<script language="javascript" type="text/javascript" src="myscript.js"></script>
<noscript>
  <p>
    This is a script.
  </p>
</noscript>

SCRIPT Special Notes:

  • JavaScript, ActionScript, and VBScript are the most common languages for scripts on the web, but you can use any type of scripting language you would like.
  • I strongly recommend using the NOSCRIPT tag whenever you use a script on your web pages to keep your pages accessible.

More SCRIPT Information:

©2012 About.com. All rights reserved.

A part of The New York Times Company.