CSSNamespaceRule: namespaceURI 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-onlynamespaceURI property of theCSSNamespaceRule returns a string containing the text of the URI of the given namespace.
In this article
Value
A string containing a URI.
Examples
The stylesheet includes a namespace as the only rule. Therefore the firstCSSRule returned will be aCSSNamespaceRule. The value of thenamespaceURI property will behttp://www.w3.org/1999/xhtml.
css
@namespace url("http://www.w3.org/1999/xhtml");js
const myRules = document.styleSheets[0].cssRules;console.log(myRules[0].namespaceURI); // 'http://www.w3.org/1999/xhtml'Specifications
| Specification |
|---|
| CSS Object Model (CSSOM)> # dom-cssnamespacerule-namespaceuri> |