Obsolete
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.

Syntax

string = node.prefix

Examples

The following logs "x" to the console.

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

Notes

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.

Specifications

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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
DeprecatedNon-standard
Chrome No support NoEdge Full support 12Firefox No support 1 — 48
Notes
No support 1 — 48
Notes
Notes This API was moved to the Element and Attr APIs according to the DOM4 standard.
Full support 5
Notes
Notes this property was read-write; starting with Firefox 5.0 it is read-only, following the specification.
IE Full support Yes
Notes
Full support Yes
Notes
Notes Only supported on Element.
Opera No support NoSafari Full support YesWebView Android No support NoChrome Android No support NoEdge Mobile Full support YesFirefox Android Full support 9Opera Android No support NoSafari iOS ? Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Last updated by: fscholz,