Web/API/Node/prefix

From Get docs
< Web/API‎ | Node

ObsoleteThis 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 SpecificationThe definition of 'Node.prefix' in that specification. Obsolete Specifies the behavior when it's set to null.
Document Object Model (DOM) Level 2 Core SpecificationThe definition of 'Initial definition' in that specification. Obsolete Initial definition

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

prefix

Deprecated'Non-standard'

Chrome

No support No

Edge

No support 12 — 79

Firefox 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 No

Safari

Full support Yes

WebView Android

No support No

Chrome Android

No support No

Firefox Android

Full support 9

Opera Android

No support No

Safari 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