This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.
The CSSNamespaceRule interface describes an object representing a single CSS @namespace at-rule.
Inherits properties from its ancestor CSSRule.
CSSNamespaceRule.namespaceURIReturns a string containing the text of the URI of the given namespace.
CSSNamespaceRule.prefixReturns a string with the name of the prefix associated to this namespace. If there is no such prefix, returns an empty string.
Inherits methods from its ancestor CSSRule.
The stylesheet includes a namespace as the only rule. Therefore the first CSSRule returned will be a CSSNamespaceRule.
@namespace url("http://www.w3.org/1999/xhtml");
const myRules = document.styleSheets[0].cssRules; console.log(myRules[0]); // A CSSNamespaceRule
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
CSSNamespaceRule |
47 | 12 | 53 | 36 | 10.1 | 47 | 53 | 36 | 10.3 | 5.0 | 47 | 10.3 |
namespaceURI |
47 | 12 | 59 | 36 | 10.1 | 47 | 59 | 36 | 10.3 | 5.0 | 47 | 10.3 |
prefix |
47 | 12 | 59 | 36 | 10.1 | 47 | 59 | 36 | 10.3 | 5.0 | 47 | 10.3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSNamespaceRule