HTML version Attribute

Beginner
⏱️ 4 min read
📚 Updated: Jun 2026
🎯 3 Examples
Legacy HTML

Introduction

The version attribute was used in early HTML to declare which HTML standard a document followed (for example HTML 4.01). It appeared on the <html> element.

Today the attribute is obsolete in HTML5. Browsers do not rely on it for rendering or document mode. Instead, modern pages use the <!DOCTYPE> declaration at the top of the file. Learning about version helps you read old markup and understand how HTML standards evolved.

What You’ll Learn

01

html only

Root element.

02

Obsolete

Not HTML5.

03

2.0–4.01

Old values.

04

DOCTYPE

Modern fix.

05

JavaScript

Demo only.

06

Legacy code

Read old sites.

Purpose of version

In early HTML specifications, the version attribute declared the HTML version a document was written in. The goal was to help user agents interpret markup according to the correct standard rules.

As HTML matured, the <!DOCTYPE> declaration became the standard way to signal document type and trigger appropriate parsing and rendering modes. HTML5 removed the version attribute from the <html> element.

💡
Use DOCTYPE in modern HTML

Start every HTML5 page with <!DOCTYPE html>. Do not add version to <html> in new projects.

📝 Syntax

Historical syntax on the root element (shown for learning only):

index.html
<html version="4.01">
<head>
  <title>Example with version attribute</title>
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>

Syntax Rules

  • Applied to the <html> element in legacy documents.
  • Value was a version string such as 2.0, 3.2, or 4.01.
  • Obsolete in HTML5 — validators flag it; browsers ignore it for mode selection.
  • Modern replacement: <!DOCTYPE html> before <html>.
  • Not the same as SVG version or app/package version numbers.
  • JavaScript can set it via document.documentElement.setAttribute("version", "4.01") for demos only.

💎 Values

The version attribute accepted version strings matching historical HTML releases:

  • 2.0 — HTML 2.0 era documents.
  • 3.2 — HTML 3.2.
  • 4.01 — HTML 4.01 (common in legacy pages).
version-values.html
<html version="2.0">...</html>
<html version="3.2">...</html>
<html version="4.01">...</html>

⚡ Quick Reference

TopicLegacy (version)Modern (HTML5)
Declaration<html version="4.01"><!DOCTYPE html>
StatusObsoleteCurrent standard
Browser effectIgnored for modeDOCTYPE triggers standards mode
Element<html>Document prologue
ValidatorWarning/error in HTML5Expected pattern
New projectsDo not useAlways use DOCTYPE

Applicable Elements

ElementSupported?Notes
<html>Historical onlyOnly element that used HTML document version
<svg>Different attributeSVG markup has its own version (e.g. 1.1) — unrelated
<head>, <body>NoNot valid on these elements
<meta>NoUse DOCTYPE, not meta version
<!DOCTYPE>Modern replacementDeclares HTML5 document type today

version vs DOCTYPE vs quirks mode

MechanismEraRole today
html version="4.01"HTML 4 / early specsObsolete; ignore in new code
<!DOCTYPE html>HTML5Required best practice
Full HTML4 DOCTYPEHTML 4.01 Strict/TransitionalLegacy maintenance only
No DOCTYPEVery old pagesMay trigger quirks mode

Examples Gallery

See legacy version on <html>, set it with JavaScript for demonstration, and compare with the modern DOCTYPE approach.

👀 Live Preview

What modern HTML5 should look like (no version attribute):

<!DOCTYPE html>
<html lang="en">
  <head>...</head>
  <body>...</body>
</html>

Implementation Example

Legacy document with version="4.01" (educational only):

index.html
<html version="4.01">
<head>
  <title>Example with version attribute</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is an example of the obsolete version attribute.</p>
</body>
</html>

How It Works

version="4.01" told early user agents the document targeted HTML 4.01 rules. Modern browsers parse the page using DOCTYPE and current HTML rules instead.

Dynamic Values with JavaScript

Educational demo: add version after the page loads:

dynamic-version.html
<script>
  document.addEventListener("DOMContentLoaded", function() {
    document.documentElement.setAttribute("version", "4.01");
  });
</script>

How It Works

The script sets version on document.documentElement (the <html> node). This does not change document mode; it is for learning how attributes can be modified dynamically.

Example — modern HTML5 replacement

The approach you should use in all new work:

html5-doctype.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Modern page</title>
</head>
<body>...</body>
</html>

How It Works

<!DOCTYPE html> is the concise HTML5 document type declaration. It replaces the old version attribute and long HTML4 DOCTYPE strings.

♿ Accessibility

  • No direct a11y impactversion is not exposed meaningfully to assistive technology.
  • Valid HTML helps everyone — Using DOCTYPE and current standards improves predictable rendering.
  • Use lang on <html> — That attribute matters for screen readers; version does not.
  • Focus on semantics — Headings, labels, and ARIA matter far more than document version metadata.
  • Maintain legacy carefully — When updating old pages, migrate to HTML5 structure rather than preserving obsolete attributes.

🧠 How version Worked (Historically)

1

Author sets version

On html element.

Legacy
2

Browser reads markup

Early parsers.

Parse
3

Rules applied

HTML 3.2 / 4.01.

Render
=

Today: DOCTYPE

HTML5 standard.

Browser Support

Browsers no longer use the version attribute on <html> for document mode or standards selection. The attribute may appear in the DOM if present, but it has no practical effect in modern HTML5 development.

⚠️ Obsolete · Ignored

Not used in HTML5

DOCTYPE determines parsing mode. Remove version when modernizing old files.

0% Modern relevance
All browsers Attribute ignored
Obsolete
HTML5 validator Flags as obsolete
Do not use
DOCTYPE html Supported
Use this
Legacy archives May contain version
Read-only
version on <html> Obsolete

Bottom line: Do not use in new HTML. Use <!DOCTYPE html> and valid HTML5 markup.

💡 Best Practices

✅ Do

  • Start pages with <!DOCTYPE html>
  • Use lang on <html> for language
  • Recognize version when reading archived HTML
  • Remove obsolete attributes when refactoring legacy sites
  • Validate with an HTML5 validator

❌ Don’t

  • Add version to new HTML5 documents
  • Assume it controls browser mode today
  • Confuse it with SVG or software version numbers
  • Skip DOCTYPE because you set version
  • Copy legacy patterns into modern templates
  • Avoid obsolete attributes like version in modern web development.
  • Use <!DOCTYPE html> to specify HTML5 for modern documents.
  • Keep HTML up to date with current standards for cross-browser compatibility.

🎉 Conclusion

The version attribute historically declared which HTML standard a document followed, but it is now obsolete. Understanding it helps you appreciate how HTML evolved from version strings on <html> to the simple DOCTYPE model used today.

In modern web development, always use <!DOCTYPE html> and focus on semantic, valid HTML5 rather than legacy version metadata.

Key Takeaways

Knowledge Unlocked

4 truths every developer should know about version

Bookmark these before your next version implementation.

4
Core concepts
📝 02

Historical values included 2.0,

Historical values included 2.0, 3.2, and 4.01.

Syntax
⚙️ 03

<!DOCTYPE html> is the

<!DOCTYPE html> is the modern replacement.

Usage
🔒 04

Browsers ignore version for

Browsers ignore version for document mode decisions today.

Dynamic

❓ Frequently Asked Questions

No. HTML5 does not use the version attribute. Use <!DOCTYPE html> instead.
Most browsers ignore it. HTML5 validators may report it as obsolete. It is safe to remove during cleanup.
They served a similar purpose (declaring document type) but DOCTYPE is the supported modern mechanism.
No. SVG has its own version attribute for SVG markup (e.g. 1.1). That is separate from the obsolete HTML document version.
Yes, with document.documentElement.getAttribute("version"), but it has no standard meaning in HTML5.

Write modern HTML5

Compare the obsolete version attribute with the correct DOCTYPE approach.

Try the DOCTYPE example →

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.

5 people found this page helpful