CSS @namespace Rule
- Previous Page mix-blend-mode
- Next Page object-fit
Definition and usage
CSS @namespace
rules are used to define an XML namespace to be used in the style sheet.
@namespace
rules must be located before all @charset
and @import
after the rule, and before all other at-rules (such as @
before the opening rule) and the style declaration.
Example
Define two XML namespaces 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 <a> elements in XHTML (because XHTML is the default namespace) */ a { color: salmon; text-decoration: none; font-weight: bold; } /* Matches all <a> elements in SVG */ svg|a { fill: maroon; text-decoration: underline; } /* Matches <a> elements in XHTML and SVG */ *|a { text-transform: uppercase; }
CSS syntax
@namspace prefix url(xmlNamspaceURL);
Attribute value
Value | Description |
---|---|
prefix | Optional. Defines the namespace prefix. |
url() | Required. The URL of the namespace. |
Browser support
The numbers in the table represent the browser version that first fully supports the @ rule.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
1 | 12 | 1 | 1 | 8 |
- Previous Page mix-blend-mode
- Next Page object-fit