Web/API/Element/prefix

From Get docs


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

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
prefix

Chrome Full support 31

Notes'

Full support 31

Notes'

Notes' This API was previously available on the Node API.

Edge

Full support 13

Firefox Full support 48

Notes'

Full support 48

Notes'

Notes' This API was previously available on the Node API.

IE

?

Opera

Full support Yes

Safari

Full support 10

WebView Android

Full support Yes

Chrome Android Full support 31

Notes'

Full support 31

Notes'

Notes' This API was previously available on the Node API.

Firefox Android Full support 48

Notes'

Full support 48

Notes'

Notes' This API was previously available on the Node API.

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android Full support 2.0

Notes'

Full support 2.0

Notes'

Notes' This API was previously available on the Node API.

Legend

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


See also