The xmlns attribute declares an XML namespace URI for an element. On the root <html> element, MDN documents the default as http://www.w3.org/1999/xhtml.
It is required when the document is parsed as XML/XHTML, and optional in normal text/html documents. In HTML parsing, the correct XHTML value has little practical effect — the parser already puts HTML elements in that namespace. Prefer a clear lang on <html> for everyday pages.
Not deprecated.
Still valid. Meaningful for XML/XHTML; mostly a compatibility marker in text/html when set to the XHTML URI.
HTML vs XML parsing.
In text/html, a correct xmlns on <html> does not change layout. Wrong or prefixed namespace declarations are not how you “add XML features” to HTML pages.
Syntax
HTML Syntax
syntax.html
<html xmlns="namespace-uri">
Common value on <html>: http://www.w3.org/1999/xhtml. On <svg>: http://www.w3.org/2000/svg.
One line:xmlns names a vocabulary for XML — optional in everyday HTML, required when the document is parsed as XML/XHTML.
Frequently Asked Questions
It declares an XML namespace URI for an element. On the root html element, the default/XHTML namespace is http://www.w3.org/1999/xhtml. It is required when the document is parsed as XML/XHTML, and optional in normal text/html documents.
No. For everyday text/html pages, the HTML parser already places elements in the XHTML namespace. xmlns on html is optional and usually has no visible effect.
When the document is served/parsed as XML (XHTML). XML parsers need an explicit namespace declaration; HTML parsers do not.
The SVG namespace is http://www.w3.org/2000/svg. In HTML documents, the parser assigns the SVG namespace to svg automatically. Writing xmlns is still common for clarity and for XML serialization.
No. It is not obsolete. In text/html it is largely a compatibility talisman when set to the XHTML URI; in XML/XHTML it remains meaningful and required on the root.
In JavaScript, read element.namespaceURI. HTML elements typically report http://www.w3.org/1999/xhtml even if xmlns was omitted from the markup.