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 AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 46
Notes
Full support 46
Notes
Notes This API was previously available on theNode API.
Edge Full support YesFirefox Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on theNode API.
IE ? Opera Full support YesSafari ? WebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on theNode API.
Opera Android ? Safari iOS ? Samsung Internet Android ?

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: sideshowbarker, fscholz, erikadoyle, Sebastianz
Last updated by: sideshowbarker,