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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
prefixChrome Full support 31
Notes
Full support 31
Notes
Notes This API was previously available on the Node API.
Edge Full support 13Firefox Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on the Node API.
IE ? Opera Full support YesSafari Full support 10WebView Android Full support YesChrome Android Full support 31
Notes
Full support 31
Notes
Notes This API was previously available on the Node API.
Edge Mobile Full support YesFirefox Android Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on the Node API.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: mdnwebdocs-bot, sideshowbarker, fscholz, erikadoyle, Sebastianz
Last updated by: mdnwebdocs-bot,