Skip to main content
HTML Validation

Bad value “http://www.w3.org/TR/REC-html40” for the attribute “xmlns” (only “http://www.w3.org/1999/xhtml” permitted here).

About This HTML Issue

The xmlns attribute declares the XML namespace for a document. The value http://www.w3.org/TR/REC-html40 is a URL that points to the old HTML 4.0 Recommendation specification — it was never a proper XML namespace identifier. It likely ended up in code through confusion between DTD/specification URLs and actual namespace URIs, or by copying markup from outdated templates.

In the HTML5 specification (the WHATWG HTML Living Standard), the xmlns attribute on the <html> element is optional. When present, its value must be exactly http://www.w3.org/1999/xhtml — no other value is permitted. This is true regardless of whether the document is served as text/html or application/xhtml+xml.

Why this matters

  • Validation failure: The W3C validator will reject the document because the namespace value is not one of the allowed values.
  • Standards compliance: Using an incorrect namespace can cause XML parsers to misinterpret or reject the document, especially when served with an XML content type.
  • Legacy confusion: The http://www.w3.org/TR/REC-html40 URL is a specification reference, not a namespace. Namespaces and specification URLs serve fundamentally different purposes in web standards.

How to fix it

The simplest fix for a standard HTML5 document is to remove the xmlns attribute entirely. The HTML parser does not require it, and browsers will process the document correctly without it.

If your document is served as XHTML (application/xhtml+xml), or if you have a specific reason to include the namespace declaration, update the value to the only permitted one: http://www.w3.org/1999/xhtml.

Examples

❌ Incorrect: old HTML 4.0 URL used as namespace

<!DOCTYPE html>
<html xmlns="http://www.w3.org/TR/REC-html40" lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

✅ Fix option 1: remove the xmlns attribute (recommended for HTML5)

For most HTML5 documents served as text/html, simply omit the attribute:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

✅ Fix option 2: use the correct namespace value

If you need the xmlns attribute (e.g., for XHTML serialization), set it to the only allowed value:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

Other incorrect values to watch for

This same error can appear with other invalid namespace URLs. All of the following are wrong:

  • http://www.w3.org/TR/REC-html40 (HTML 4.0 spec URL)
  • http://www.w3.org/TR/html4/ (another HTML 4 spec URL)
  • http://www.w3.org/1999/html (non-existent namespace)

The only valid value is http://www.w3.org/1999/xhtml. When in doubt, remove the xmlns attribute altogether — modern HTML5 documents don’t need it.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your trial today.