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 |
---|---|---|
DOMThe 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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
prefix
|
Chrome Full support 31 Full support 31 Notes' This API was previously available on the |
Edge
Full support 13 |
Firefox Full support 48 Full support 48 Notes' This API was previously available on the |
IE
? |
Opera
Full support Yes |
Safari
Full support 10 |
WebView Android
Full support Yes |
Chrome Android Full support 31 Full support 31 Notes' This API was previously available on the |
Firefox Android Full support 48 Full support 48 Notes' This API was previously available on the |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android Full support 2.0 Full support 2.0 Notes' This API was previously available on the |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.'
- See implementation notes.
See also
Element.prefix by Mozilla Contributors is licensed under CC-BY-SA 2.5.