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

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes)
No support46.0[1]
No support 48.0 (48.0)[1]
? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes)[2]
No support 48.0 (48.0)[1]
? ? ?

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

[2] Prior to Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2), this property was read-write; starting with Gecko 5.0 it is read-only, following the specification.

See also

Document Tags and Contributors

 Last updated by: teoli,