HTML language Attribute

The obsolete HTML language attribute was historically used on the <script> element to identify the scripting language used by the enclosed or referenced script.

Historical Syntax

The language attribute was placed on the <script> element and commonly given the value JavaScript:

<script language="JavaScript">
  document.write("Hello, World!");
</script>

Authors also used version-like values such as JavaScript1.2 in an attempt to identify a particular version or variation of the scripting language.

Historical Elements

The obsolete language attribute was associated with the <script> element.

Element Historical Purpose
<script> Identified the scripting language used by the script.

Historical Use

Early webpages could contain scripts written for different scripting environments. The language attribute gave authors a way to indicate which scripting language a particular <script> element was intended to use.

JavaScript became the standard scripting language used on the web, and markup such as language="JavaScript" became unnecessary. The attribute was eventually made obsolete.

The language attribute should not be confused with the current global lang attribute. The lang attribute identifies the human language of text, such as English, Spanish, or French. It does not identify a programming or scripting language.

Why It Became Obsolete

The language attribute became unnecessary as the web's scripting model was standardized. Modern HTML defines how scripts are handled without requiring authors to declare language="JavaScript".

Removing the obsolete attribute also produces simpler markup and avoids old version-specific values that do not belong in modern HTML.

Modern Alternative

For ordinary JavaScript, simply use the <script> element without the obsolete language attribute.

Historical HTML

<script language="JavaScript">
  console.log("Hello, World!");
</script>

Modern HTML

<script>
  console.log("Hello, World!");
</script>

No replacement attribute is required for ordinary JavaScript. Modern HTML treats a <script> element without a type attribute as a classic JavaScript script.

The current type attribute has specific modern uses. For example, type="module" identifies a JavaScript module:

<script type="module" src="app.js"></script>

The type attribute should therefore not be added merely as a replacement for the old language="JavaScript" markup.

Legacy Browser Support

The language attribute was widely recognized by older browsers because it appeared frequently in scripts on early webpages.

Modern browsers may continue to recognize some legacy uses for compatibility with older content, but new and updated webpages should omit the attribute and use modern <script> syntax.

For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.

Other attributes related to scripts or language identification include:

  • event - An obsolete attribute historically used to associate a script with an event.
  • type - A current attribute with specific uses on the <script> element, including identifying JavaScript modules with type="module".
  • lang - A current global attribute used to identify the human language of an element's content.

Specifications

The language attribute on the <script> element is obsolete and should not be used in new content. Modern HTML does not require an attribute to identify ordinary JavaScript. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.