CSSNamespaceRule: prefix property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2018.

The read-only prefix property of the CSSNamespaceRule returns a string with the name of the prefix associated to this namespace. If there is no such prefix, it returns an empty string.

Value

A string containing the prefix associated to this namespace. If there is no prefix an empty string.

Examples

The stylesheet includes two namespace rules. The first has no prefix the second the prefix svg. Two CSSNamespaceRule objects will be returned. The value of the prefix property for the first will be an empty string, for the second svg.

css
@namespace url("http://www.w3.org/1999/xhtml");
@namespace svg url("http://www.w3.org/2000/svg");
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].prefix); // an empty string ""
console.log(myRules[1].prefix); // "svg"

Specifications

Specification
CSS Object Model (CSSOM)
# dom-cssnamespacerule-prefix

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
prefix
Chrome – Full support
Chrome 47 (Release date: 2015-12-01)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 59 (Release date: 2018-03-13)
footnote Full support
Opera – Full support
Opera 36 (Release date: 2016-03-15)
footnote Full support
Safari – Full support
Safari 10.1 (Release date: 2017-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 47 (Release date: 2015-12-02)
footnote Full support
Firefox for Android – Full support
Firefox for Android 59 (Release date: 2018-03-13)
footnote Full support
Opera Android – Full support
Opera Android 36 (Release date: 2016-03-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10.3 (Release date: 2017-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 47 (Release date: 2015-12-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10.3 (Release date: 2017-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support