The Element.prefix
read-only property returns the namespace prefix of the specified element, or null
if no prefix is specified.
Before DOM4 this API was defined within the Node
interface.
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 |
---|---|---|
DOM The definition of 'Element: prefix' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
prefix | Chrome
Full support
31
| Edge Full support 13 | Firefox
Full support
48
| IE ? | Opera Full support Yes | Safari Full support 10 | WebView Android Full support Yes | Chrome Android
Full support
31
| Firefox Android
Full support
48
| Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android
Full support
2.0
|
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.