CSSNamespaceRule

Baseline Widely available

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

The CSSNamespaceRule interface describes an object representing a single CSS @namespace at-rule.

CSSRule CSSNamespaceRule

Instance properties

Inherits properties from its ancestor CSSRule.

CSSNamespaceRule.namespaceURI

Returns a string containing the text of the URI of the given namespace.

CSSNamespaceRule.prefix

Returns a string with the name of the prefix associated to this namespace. If there is no such prefix, returns an empty string.

Instance methods

Inherits methods from its ancestor CSSRule.

Examples

The stylesheet includes a namespace as the only rule. Therefore the first CSSRule returned will be a CSSNamespaceRule.

css
@namespace url(http://www.w3.org/1999/xhtml);
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); //a CSSNamespaceRule

Specifications

Specification
CSS Object Model (CSSOM)
# the-cssnamespacerule-interface

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CSSNamespaceRule
namespaceURI
prefix

Legend

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

Full support
Full support