👀 Live Preview
What modern HTML5 should look like (no version attribute):
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body>...</body>
</html>
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.
Root element.
Not HTML5.
Old values.
Modern fix.
Demo only.
Read old sites.
versionIn 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.
Start every HTML5 page with <!DOCTYPE html>. Do not add version to <html> in new projects.
Historical syntax on the root element (shown for learning only):
<html version="4.01">
<head>
<title>Example with version attribute</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html><html> element in legacy documents.2.0, 3.2, or 4.01.<!DOCTYPE html> before <html>.version or app/package version numbers.document.documentElement.setAttribute("version", "4.01") for demos only.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).<html version="2.0">...</html>
<html version="3.2">...</html>
<html version="4.01">...</html>| Topic | Legacy (version) | Modern (HTML5) |
|---|---|---|
| Declaration | <html version="4.01"> | <!DOCTYPE html> |
| Status | Obsolete | Current standard |
| Browser effect | Ignored for mode | DOCTYPE triggers standards mode |
| Element | <html> | Document prologue |
| Validator | Warning/error in HTML5 | Expected pattern |
| New projects | Do not use | Always use DOCTYPE |
| Element | Supported? | Notes |
|---|---|---|
<html> | Historical only | Only element that used HTML document version |
<svg> | Different attribute | SVG markup has its own version (e.g. 1.1) — unrelated |
<head>, <body> | No | Not valid on these elements |
<meta> | No | Use DOCTYPE, not meta version |
<!DOCTYPE> | Modern replacement | Declares HTML5 document type today |
version vs DOCTYPE vs quirks mode| Mechanism | Era | Role today |
|---|---|---|
html version="4.01" | HTML 4 / early specs | Obsolete; ignore in new code |
<!DOCTYPE html> | HTML5 | Required best practice |
| Full HTML4 DOCTYPE | HTML 4.01 Strict/Transitional | Legacy maintenance only |
| No DOCTYPE | Very old pages | May trigger quirks mode |
See legacy version on <html>, set it with JavaScript for demonstration, and compare with the modern DOCTYPE approach.
What modern HTML5 should look like (no version attribute):
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body>...</body>
</html>Legacy document with version="4.01" (educational only):
<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>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.
Educational demo: add version after the page loads:
<script>
document.addEventListener("DOMContentLoaded", function() {
document.documentElement.setAttribute("version", "4.01");
});
</script>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.
The approach you should use in all new work:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modern page</title>
</head>
<body>...</body>
</html><!DOCTYPE html> is the concise HTML5 document type declaration. It replaces the old version attribute and long HTML4 DOCTYPE strings.
version is not exposed meaningfully to assistive technology.lang on <html> — That attribute matters for screen readers; version does not.On html element.
Early parsers.
HTML 3.2 / 4.01.
HTML5 standard.
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.
DOCTYPE determines parsing mode. Remove version when modernizing old files.
<html> ObsoleteBottom line: Do not use in new HTML. Use <!DOCTYPE html> and valid HTML5 markup.
<!DOCTYPE html>lang on <html> for languageversion when reading archived HTMLversion to new HTML5 documentsversion in modern web development.<!DOCTYPE html> to specify HTML5 for modern documents.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.
versionBookmark these before your next version implementation.
version on <html> is obsolete in HTML5.
Historical values included 2.0, 3.2, and 4.01.
<!DOCTYPE html> is the modern replacement.
Browsers ignore version for document mode decisions today.
version attribute. Use <!DOCTYPE html> instead.version attribute for SVG markup (e.g. 1.1). That is separate from the obsolete HTML document version.document.documentElement.getAttribute("version"), but it has no standard meaning in HTML5.Compare the obsolete version attribute with the correct DOCTYPE approach.
5 people found this page helpful