language (HTML attribute)
| Depr. | Version |
|---|---|
| Yes | N/A |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Buggy | Full |
Syntax
Description
The
language attribute tells the browser which
scripting language is to be used inside the script
block (or in the file referred to by the src
attribute, as shown in the example). It may be the name of the scripting
language, or a version-specific implementation of the language (see the
values below).
Note that the language
attribute is nonstandard, and harks back to the days of what were known as
the “browser wars.” The appropriate way to identify the contents of the
script element is through the type attribute (for
example, you might specify the content as
"text/javascript"), and use JavaScript object/feature
detection techniques within the script rather than assume that all
browsers which support a given version of a scripting language support all
of the features of that language—no questions asked.
Example
In this example, a series of
script blocks are being used to identify the browser’s
script capability:
<p>
<script language="JavaScript1.2">
document.write("1.2");
</script>
</p>
<p>
<script language="JavaScript1.5">
document.write("1.5");
</script>
</p>
<p>
<script language="JavaScript3.5">
document.write("3.5 Does not exist yet");
</script>
</p>
<p>
<script language="wibblewobble">
document.write("No such language");
</script>
</p>
<p>
<script language="VBscript">
document.write("VB script");
</script>
</p>
Value
The values that can be used in this attribute are:
"JavaScript","JavaScript1.1","JavaScript1.2","JavaScript1.3""JScript""VBScript""vbs"
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Buggy | Buggy | Buggy | Full |
Using the test shown
in the example, most browsers behaved as expected, running only the
scripts that they should be capable of running. Opera (all versions)
didn’t attempt to run the code inside the last two script blocks, but
incorrectly ran the third one (the non-existent JavaScript 3.5 language),
However, if the script tag also includes
type=”text/javascript”, then the
language attribute is completely ignored—all of the
scripts in the example above would run
regardless.
User-contributed notes
There are no comments yet.