Skip to main content

HTML Guide

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

Only http://www.w3.org/1999/xhtml is allowed as the value for the xmlns attribute in HTML5 documents.

The xmlns attribute specifies the XML namespace of an element and is mainly used with XHTML documents. For HTML5, the correct value is http://www.w3.org/1999/xhtml, and typically you don’t need to include the xmlns attribute at all unless you are serving your document as application/xhtml+xml (XHTML). Using the http://www.w3.org/TR/REC-html40 value is invalid and will trigger validator errors.

Correct code for a standard HTML5 document:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Valid HTML5 Example</title>
  </head>
  <body>
    <!-- Page content -->
  </body>
</html>

If you are using XHTML and need the namespace:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <title>Valid XHTML Example</title>
  </head>
  <body>
    <!-- Page content -->
  </body>
</html>

For HTML5, simply remove the xmlns attribute or, if serving as XHTML, ensure the value is exactly http://www.w3.org/1999/xhtml.

Related W3C validator issues