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.
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.
A string containing the prefix associated to this namespace. If there is no prefix an empty string.
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].namespaceURI); // an empty string "" console.log(myRules[1].namespaceURI); // "svg"
Specification |
---|
CSS Object Model (CSSOM) # dom-cssnamespacerule-prefix |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
prefix |
47 | 12 | 59 | 9 | 36 | 10.1 | 47 | 47 | 59 | 36 | 10.3 | 5.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSNamespaceRule/prefix