HTML and CSS Reference
In earlier versions of HTML, the language attribute was used in place of the type
attribute to indicate the script language. Thus if you are working with legacy pages you
The language attribute has been deprecated and is not supported in either HTML5 or
XHTML, so you should use the type attribute in its place if you want to conform to the
Note that the script element can be used with programming languages other than
for the type attribute. For example, if you use VBScript from Microsoft, the MIME type is
text/vbscript. You won't use VBScript in this tutorial.
Embedding a Script
• To place a script element in a Web page, insert the two-sided tag
<scriptƒtype=” mime-type ”>
where mime-type defines the language in which the script is written and
scriptƒcommands represents commands written in the scripting language.
Placing the script element
When a browser encounters a script element within a file, it treats any lines within
the element as commands to be run, processing the commands in the order in which
they appear within the file. There is no limit to the number of script elements that you
can use within a Web page. Scripts can be placed in either the head section or the body
section of a document. When placed in the body section, a browser interprets and runs
them as it loads the different elements of the Web page. Although a single page can
contain many script elements, the browser still works with them as a single unit. As a
other script elements in the HTML file.
statements. Each statement —also known as a command —is a single line that indicates
an action for the browser to take. A statement should end in a semicolon, employing the
the official way of notifying the browser that it has reached the end of the statement.
Most browsers are very forgiving and still interpret most statements correctly even if you
neglect to include the ending semicolon. However, it is good programming practice to
include the semicolons, and some browsers require them.