The CSSNamespaceRule
interface describes an object representing a single CSS @namespace
at-rule
.
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="https://developer.mozilla.org/en-US/docs/Web/API/CSSRule" target="_top"><rect x="1" y="1" width="75" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="38.5" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">CSSRule</text></a><polyline points="76,25 86,20 86,30 76,25" stroke="#D4DDE4" fill="none"/><line x1="86" y1="25" x2="116" y2="25" stroke="#D4DDE4"/><a xlink:href="https://developer.mozilla.org/en-US/docs/Web/API/CSSNamespaceRule" target="_top"><rect x="116" y="1" width="160" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="196" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">CSSNamespaceRule</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
Properties
Inherits methods from its ancestor CSSRule
.
CSSNamespaceRule.namespaceURI
- Returns a
DOMString
containing the text of the URI of the given namespace. CSSNamespaceRule.prefix
- Returns a
DOMString
with the name of the prefix associated to this namespace. If there is no such prefix, returns an empty string.
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
.
@namespace url(http://www.w3.org/1999/xhtml);
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); //a CSSNamespaceRule
Specifications
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) The definition of 'CSSNamespaceRule' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser