CSS @namespace Rule
Example
Define two XML namespaces to be used in the style sheet:
@namespace url(http://www.w3.org/1999/xhtml); /* default namespace */
@namespace svg url(http://www.w3.org/2000/svg); /* prefixed namespace */
/* matches all XHTML <a> elements (since XHTML is the default namespace */
a {
color: salmon;
text-decoration: none;
font-weight: bold;
}
/* matches all SVG <a> elements */
svg|a {
fill: maroon;
text-decoration: underline;
}
/* matches both XHTML and SVG <a>
elements */
*|a {
text-transform: uppercase;
}
Try it Yourself »
Definition and Usage
The CSS @namespace
rule is used to
define an XML namespace to be used in the style sheet.
The @namespace
rule must follow all
@charset and
@import rules, and precede all other at-rules and style declarations in a
style sheet.
Browser Support
The numbers in the table specify the first browser version that fully supports the at-rule.
At-rule | |||||
---|---|---|---|---|---|
@namespace | 1 | 12 | 1 | 1 | 8 |
CSS Syntax
@namspace prefix url(xmlNamspaceURL);
Property Values
Value | Description |
---|---|
prefix | Optional. Defines a namespace prefix |
url() | Required. The URL of the namespace |