namespaceURI (W3C DOM Core property)

Version Depr. Static Read-only
DOM2 No No Yes
Browser support (more…)
IE5.5+ FF1.5+ SA1.3+ OP9+
Full Full Full Full


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" lang="en" xml:lang="en">

The example above shows the bare bones of an XHTML document. We could then retrieve the root namespace like this:

var ns = document.documentElement.namespaceURI;

If the document is in XHTML mode1 then the ns variable will have the value; for HTML mode2 it will be null.


The namespace URI of an Element or Attr node. For other nodes, or elements or attributes created with a DOM 1 method that isn't namespace aware (such as createElement), or nodes with no namespace, this property is null.

This should not be a computed value or lookup of the namespace an element should have, it should be the literal value that it does have.

An Element node can inherit its namespace from an ancestor. However Attr nodes do not inherit a namespace from the element they're attached to — if an attribute does not have an explicitly defined namespace then it simply has no namespace.

This property is readonly.


Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
Full Full Full Full Full Full Full Full Full Full Full
: Behavior in HTML

Since namespaceURI is an XML construct, it's only reasonable to judge its behavior in terms of XML (either on HTML pages in XHTML mode3, or pure XML). The behavioral variations of browsers in HTML mode4 are documented here for interest and reference, but the support summary table above does not consider this behavior (ie. if the property is fully supported in XML then it's considered to be fully supported, with no notes).

Internet Explorer in HTML doesn't implement this property (it returns undefined).

Safari 3 in HTML mode returns the XHTML namespace for all HTML elements, even in documents that aren't XHTML (eg. HTML 4).


1 On XHTML pages served as application/xhtml+xml.

2 On XHTML or HTML pages served as text/html.

3 On XHTML pages served as application/xhtml+xml.

4 On XHTML or HTML pages served as text/html.

User-contributed notes

There are no comments yet.

Related Products