The language attribute on <script> was an early way to name the scripting language (usually language="JavaScript"). Its values were never well standardized.
It is notlang (page/content language). For new work, omit language entirely, or use type for modules and non-JS script blocks.
Deprecated / obsolete.
Do not use language in new pages. The HTML Standard says omit it. Learn it only to read legacy HTML and migrate safely.
Syntax
HTML Syntax
syntax.html
<script language="JavaScript"> … </script>
Modern equivalent:<script>…</script> (no language), or <script type="module"> when you need modules.
Values
Attribute Values
Historical values you may still see in old code:
Value
Description
Try it
JavaScript / javascript
Legacy “this is JS” hint. If present, HTML says it should match this string (ASCII case-insensitive) and has no useful effect — omit it
Compare legacy markup with the modern form. The demo button runs either way — language does not change behavior.
markup style
Study the snippet. Prefer the modern form in real projects.
Snippet
<script language="JavaScript">
// deprecated — omit in new code
</script>
Legacy: language is present but unused by modern engines.
Code
HTML Examples
Short study snippets. Use Try It Yourself for a live editor. Prefer the modern patterns in production.
Example 1 — Recognize Legacy Markup
Old pages often wrote language="javascript". Scripts still run; the attribute is obsolete.
HTML
<!-- Deprecated — for study only -->
<button type="button" id="go">Click me</button>
<script language="javascript">
document.getElementById("go").addEventListener("click", function () {
alert("Script runs; language is ignored.");
});
</script>
Default is JavaScript. A classic <script> needs no language hint.
Modules use type.type="module" (and related types) replace old language hacks.
Spec advice. If you ever wrote language="JavaScript", delete it — same behavior.
Keep loading attrs. Use src, defer, async as needed — not language.
Example 3 — language vs lang
Page language and script language are different jobs — only lang belongs on content.
HTML
<!-- Correct: natural language of the page -->
<html lang="en">
<body>
<p>This document is English.</p>
<!-- Correct: classic script with no language attribute -->
<script>
console.log(document.documentElement.lang); // "en"
</script>
</body>
</html>
<!-- Wrong: do not use language for page language -->
<!-- <script language="en">...</script> -->
Most mistakes are copying old tutorials or confusing language with lang.
obsolete
Authors should omit it
Even language="JavaScript" should be removed. It does not improve modern pages.
type
type wins
If a type attribute is present, language is ignored. Prefer type for non-classic scripts.
compare
Not page language
Use lang on <html> (and nested elements). Never use language for that.
migrate
Search-and-delete safely
Removing language="…" from classic scripts is usually a no-op fix. Keep src, defer, async, and type="module" intact.
js
Do not setAttribute("language", …)
Dynamic script injection should set src / textContent / type only — never resurrect language.
Compatibility
Browser Support
language is a legacy HTML attribute on <script>. Engines may still parse it for old pages, but it is obsolete for authors.
✓ Deprecated · Do not use
language
Recognized in legacy documents. New sites must omit it. Prefer plain script or the type attribute.
LegacyCompatibility only
Google ChromeParses legacy; ignore for authors
Legacy*
Mozilla FirefoxParses legacy; ignore for authors
Legacy*
Apple SafariParses legacy; ignore for authors
Legacy*
Microsoft EdgeParses legacy; ignore for authors
Legacy*
OperaParses legacy; ignore for authors
Legacy*
Samsung InternetParses legacy; ignore for authors
Legacy*
Internet ExplorerLegacy attribute era
Legacy*
language on <script>Obsolete for authors
Bottom line: *Do not ship language in new HTML. Support exists only so old pages keep working.
Remember
Key Takeaways
Status: deprecated / obsolete on <script> — omit in new code.
Replace with: plain <script> or type (modules / data blocks).
Not lang: page language uses the lang attribute.
Goal: recognize legacy markup; never introduce it in new tutorials or apps.
One line: drop language from scripts — use nothing for classic JS, or type when you need a special script kind.
Frequently Asked Questions
A legacy attribute on script that tried to name the scripting language (often language="JavaScript"). It is obsolete in modern HTML and should not be used in new pages.
No. language on script is a deprecated scripting hint. lang is a global attribute that declares the natural language of page content (for example html lang="en").
No. The HTML Standard says authors should omit it. For classic JavaScript, use a plain script tag. For modules or data blocks, use the type attribute.
With the value JavaScript it has no useful effect in conforming documents. If type is also present, language is ignored. Prefer omitting language entirely.
Omit the attribute for normal JavaScript, or use type (for example type="module", type="importmap", or a MIME type for a data block). Do not invent new language values.
So you can recognize it in old tutorials and codebases, avoid copying it into new work, and migrate safely to modern script markup.