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

Syntax

string = element.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
DOM4
The definition of 'Node.prefix' in that specification.
Working Draft  
Document Object Model (DOM) Level 3 Core Specification
The definition of 'Node.prefix' in that specification.
Recommendation 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.
Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? (Yes)[1] ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes)[1] ? ? ?

[1] 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.

Document Tags and Contributors

 Last updated by: flimzy,