node.isDefaultNamespace(namespaceURI) returns true if that URI is the node’s default namespace, otherwise false(MDN).
Status: Baseline Widely available (since July 2015) — not Deprecated, Experimental, or Non-standard. In HTML pages, namespace results can differ by browser — prefer createElementNS for clear demos.
Remember
node.isDefaultNamespace(namespaceURI)
→ true | false
Same as:
node.lookupNamespaceURI(null) === namespaceURI
"" ≡ null (empty string treated like null)
Common URIs:
http://www.w3.org/1999/xhtml
http://www.w3.org/2000/svg
http://www.w3.org/1998/Math/MathML
Node.isDefaultNamespace() is marked Baseline Widely available on MDN (since July 2015).
✓ Baseline · Widely available
Node.isDefaultNamespace()
Returns whether a namespace URI is the node’s default namespace. Equivalent to comparing lookupNamespaceURI(null). HTML-document results can differ by engine.
The call itself is inexpensive. Namespace work is rare in typical UI code — use it when building or validating XML / SVG / MathML trees.
Remember
Key Takeaways
Boolean check: is this URI the node’s default namespace?
Equivalent to:lookupNamespaceURI(null) === uri.
"" ≡ null: empty string means no namespace URI.
Demo tip: use createElementNS — HTML pages can disagree across browsers.
One line:isDefaultNamespace(uri) answers whether uri is that node’s default namespace — the short form of comparing lookupNamespaceURI(null).
Frequently Asked Questions
It returns true if the given namespace URI is the default namespace for that node, and false otherwise.
No. MDN marks Node.isDefaultNamespace() as Baseline Widely available (since July 2015). It is a standard DOM method — not Deprecated, Experimental, or Non-standard.
MDN: isDefaultNamespace(namespaceURI) is equivalent to node.lookupNamespaceURI(null) === namespaceURI. Passing null to lookupNamespaceURI retrieves the default namespace.
Yes. namespaceURI is required in the signature but may be null. The empty string is treated as equivalent to null.
MDN notes that in HTML documents, xmlns: attributes are mostly ignored. Firefox may report null namespaces for elements, while Chrome and Safari set HTML, SVG, and MathML default namespaces more consistently. Prefer createElementNS or an SVG document for clearer tests.
When working with XML, SVG, MathML, or mixed documents and you need to know whether a URI is that node’s default namespace before creating or moving namespaced nodes.