Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The Node.prefix
read-only property returns the namespace
prefix of the specified node, or null
if no prefix is specified.
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
BCD tables only load in the browser