W3cubDocs

/DOM

Node.prefix

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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support No 12 1 — 48
1 — 48
This API was moved to the Element and Attr APIs according to the DOM4 standard.
5
this property was read-write; starting with Firefox 5.0 it is read-only, following the specification.
Yes
Yes
Only supported on Element.
No Yes
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support No No Yes 9 No ? No

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/prefix