HTML Value Syntax

XML xmlns namespace declaration

In XML syntax, an xmlns declaration sets the default namespace for unprefixed element names in its scope. It does not place ordinary unprefixed attributes in that namespace. In text/html, namespace assignment follows the HTML parser rules instead; an xmlns attribute is not a way to switch parsers or assign arbitrary namespaces to HTML elements. Namespace URIs identify vocabularies and need not be fetched.

Formal Syntax & Structure

html syntaxhtml
xmlns="http://www.w3.org/1999/xhtml"

Parameters & Attributes

NameTypeDescription
xmlnsnamespace URIDefault namespace identifier for XML element names in scope.

Working Example

Example Snippethtml
<output id="result"></output><script>  const doc=new DOMParser().parseFromString('<root xmlns="urn:example:notes"><item id="one"/></root>',"application/xml");const item=doc.documentElement.firstElementChild;document.querySelector("#result").textContent=item.namespaceURI+" / "+String(item.getAttributeNode("id").namespaceURI);</script>
HTML Reference