This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The Node.prefix read-only property returns the namespace prefix of the specified node, or null if no prefix is specified.

In DOM4 this API was moved from Node to the Element and Attr interfaces.


string = node.prefix


The following logs "x" to the console.

<x:div onclick="console.log(this.prefix)"/>


This will only work when a namespace-aware parser is used, i.e. when a document is served with an XML MIME type. This will not work for HTML documents.


Specification Status Comment
Document Object Model (DOM) Level 3 Core Specification
The definition of 'Node.prefix' in that specification.
Obsolete Specifies the behavior when it's set to null.
Document Object Model (DOM) Level 2 Core Specification
The definition of 'Initial definition' in that specification.
Obsolete Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support No Yes

1 — 481


Yes3 No Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support No No Yes9 No ? ?

1. This API was moved to the Element and Attr APIs according to the DOM4 standard.

2. this property was read-write; starting with Firefox 5.0 it is read-only, following the specification.

3. Only supported on Element.

See also

Document Tags and Contributors

 Last updated by: fscholz,