HTML version Attribute

Beginner
4 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

version was an attribute on the <html> root. It claimed which HTML DTD version governed the document. That information already lived in the document type declaration, so the attribute was always redundant.

The HTML Standard lists version on html as obsolete: unnecessary — omit it. Use <!DOCTYPE html> plus lang on the root instead.

Deprecated / obsolete.

Do not put version on <html>. Learn it only to recognize old markup and migrate to a modern DOCTYPE.

HTML Syntax

syntax.html
<!-- obsolete --> <html version=" …">

Modern form: <!DOCTYPE html> then <html lang="en"> — no version attribute.

Attribute Values

Historical strings (study only). None are required today:

Value / formDescriptionTry it
version="-//W3C//DTD HTML 4.01//EN"Common legacy DTD-style string on htmlTry it
Other CDATA stringsHTML 4.01 allowed free-form version text — never standardized for HTML5Try it
(omit)Correct today — never add this attributeTry it
<!DOCTYPE html>Modern document type — replaces versioning on the rootTry it
lang on htmlUseful modern root attribute (language of the page)Try it

Live Preview

Compare obsolete version markup with a modern HTML5 skeleton. Prefer the modern snippet.

markup style

Study only — version on html is obsolete; use <!DOCTYPE html>.

Snippet
<!-- obsolete — do not use -->
<html version="-//W3C//DTD HTML 4.01//EN">
  …
</html>

Obsolete version attribute — redundant with the DOCTYPE; omit it.

HTML Examples

Study snippets. Use Try It Yourself for a live editor. Prefer modern patterns in production.

Example 1 — Recognize Obsolete Markup

Old pages sometimes put a DTD-like string on <html>. Do not copy this.

HTML
<!-- Obsolete — for study only -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html version="-//W3C//DTD HTML 4.01//EN">
  <head>
    <title>Legacy root</title>
  </head>
  <body>
    <p>The version attribute adds nothing useful here.</p>
  </body>
</html>
Try It Yourself

How It Works

  1. DOCTYPE already stated the DTD — that was the real version signal.
  2. version repeated it — redundant metadata on the root.
  3. Browsers ignore it for parsing mode — the DOCTYPE (or lack of one) matters more.
  4. Action — delete version when you find it.

Example 2 — Modern HTML5 Document

One short DOCTYPE. No version attribute on the root.

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Modern page</title>
  </head>
  <body>
    <p>Standards mode without a version attribute.</p>
  </body>
</html>
Try It Yourself

How It Works

  1. <!DOCTYPE html> — triggers standards mode in browsers.
  2. Omit version — the living standard says it is unnecessary.
  3. charset + viewport — practical head basics for every page.
  4. One root — a single <html> wrapping head and body.

Example 3 — Useful Root Attributes Instead

Prefer lang (and, in XML-serialized XHTML, xmlns) — not version.

HTML
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="UTF-8">
    <title>Language on the root</title>
  </head>
  <body>
    <p>lang helps accessibility, search, and hyphenation — version does not.</p>
  </body>
</html>
Try It Yourself

How It Works

  1. lang — declares the primary language of the page.
  2. Screen readers & SEO — benefit from a correct language tag.
  3. xmlns — only needed for XML/XHTML parsing, not for everyday HTML5.
  4. Skip obsolete root flags — including version and the old manifest attribute.

Edge Cases & Pitfalls

Most confusion is treating version as a live HTML5 switch or reading it from JavaScript.

obsolete

Authors must not use it

WHATWG: version on html is obsolete — omit it. Spec replacement: nothing; use the DOCTYPE.

DOCTYPE

DOCTYPE controls standards mode

Missing or quirky DOCTYPEs affect layout quirks. A version attribute does not fix that — put <!DOCTYPE html> first.

IDL

HTMLHtmlElement.version

Deprecated DOM property; often returns an empty string. Do not depend on it for feature detection.

naming

Not a software version

This attribute is not package.json, API, or HTTP versioning. It was only a DTD label on the root.

migrate

Search and delete

Strip version="…" from legacy roots; keep or add lang and a modern DOCTYPE.

Browser Support

version is an obsolete HTML attribute on <html>. Authors must not use it; engines do not need it for parsing.

✓ Obsolete · Do not use

version

Harmless if present, but non-conforming. Prefer and lang on the root. Do not read HTMLHtmlElement.version for real version data.

0% Author use (do not)
Google Chrome Ignored for authors
Do not use
Mozilla Firefox IDL empty / ignore
Do not use
Apple Safari Ignored for authors
Do not use
Microsoft Edge Ignored for authors
Do not use
Opera Ignored for authors
Do not use
Samsung Internet Ignored for authors
Do not use
Internet Explorer Historical
Do not use
version Obsolete

Bottom line: Study only. Delete version from legacy

tags; use and lang instead.

Key Takeaways

  • Status: obsolete — authors must not use it.
  • Old idea: label the HTML DTD on the root (redundant).
  • Replace with: <!DOCTYPE html>.
  • Prefer on root: lang (not version).

One line: version on <html> was a redundant DTD label — omit it and start pages with <!DOCTYPE html>.

Frequently Asked Questions

An attribute on the <html> root that claimed which HTML DTD version governed the document. It was redundant with the document type declaration and is obsolete.
No. The WHATWG HTML Standard lists version on html as obsolete: Unnecessary. Omit it altogether. Use <!DOCTYPE html> and a modern <html lang="…"> root.
Start every page with <!DOCTYPE html>. That switches the browser into standards mode. You do not put a version number on the html element.
The legacy HTMLHtmlElement.version IDL property is deprecated. In practice it is empty or useless — do not read version information from it.
No. This page is only about the obsolete HTML attribute on <html>. Software versioning is unrelated.
Deprecated / obsolete — not experimental. Study it only to recognize old markup.

Next: vspace

Obsolete vertical spacing — prefer CSS margins instead.

vspace tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful