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

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-http-www-w3-org-tr-rec-html40-for-the-attribute-xmlns-only-http-www-w3-org-1999-xhtml-permitted-here
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

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

```html
<!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:

```html
<!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:

```html
<!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.
