W3cubDocs

/Web APIs

Node: isDefaultNamespace() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The isDefaultNamespace() method of the Node interface accepts a namespace URI as an argument. It returns a boolean value that is true if the namespace is the default namespace on the given node and false if not.

Note: The default namespace of an HTML element is always "". For a SVG element, it is set by the xmlns attribute.

Syntax

isDefaultNamespace(namespaceURI)

Parameters

namespaceURI

A string representing the namespace against which the element will be checked.

Note: namespaceURI is not an optional parameter, but can be null.

Return value

A boolean value that holds the return value true or false, indicating if the parameter is the default namespace, or not.

Example

Is "" the default namespace for <output>:
<output>Not tested</output>.<br />
Is "http://www.w3.org/2000/svg" the default namespace for &lt;output&gt;:
<output>Not tested</output>.<br />
Is "" the default namespace for &lt;svg&gt;: <output>Not tested</output>.<br />
Is "http://www.w3.org/2000/svg" the default namespace for &lt;svg&gt;:
<output>Not tested</output>.<br />
<svg xmlns="http://www.w3.org/2000/svg" height="1"></svg>
<button>Click to run tests</button>
const button = document.querySelector("button");
button.addEventListener("click", () => {
  const htmlElt = document.querySelector("output");
  const svgElt = document.querySelector("svg");

  const result = document.getElementsByTagName("output");
  result[0].value = htmlElt.isDefaultNamespace(""); // true
  result[1].value = htmlElt.isDefaultNamespace("http://www.w3.org/2000/svg"); // false
  result[2].value = svgElt.isDefaultNamespace(""); // false
  result[3].value = svgElt.isDefaultNamespace("http://www.w3.org/2000/svg"); // true
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
isDefaultNamespace 1 12 1 ≤12.1 3 18 4 ≤12.1 1 1.0 4.4 1

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/isDefaultNamespace