Group: csswg Shortname: css-namespace Level: 3 Status: ED ED: http://dev.w3.org/csswg/css-namespaces/ TR: http://www.w3.org/TR/css3-namespace/ Test Suite: http://test.csswg.org/suites/css3-namespace/20090210/ Editor: Elika J. Etemad, Invited Expert, http://fantasai.inkedblade.net/contact Former Editor: Anne van Kesteren, Opera Software ASA Former Editor: Peter Linss, Netscape Communications Former Editor: Chris Lilley, W3C Previous Version: http://www.w3.org/TR/2008/CR-css3-namespace-20080523/ Abstract: This CSS Namespaces module defines the syntax for using namespaces in CSS. It defines the ''@namespace'' rule for declaring the default namespace and binding namespaces to namespace prefixes, and it also defines a syntax that other specifications can adopt for using those prefixes in namespace-qualified names. Link Defaults: selectors-4 (dfn) type selectors, css-syntax-3 (dfn) at-rule Boilerplate: omit footer
A document or implementation cannot conform to CSS Namespaces alone, but can claim conformance to CSS Namespaces if it satisfies the conformance requirements in this specification when implementing CSS or another host language that normatively references this specification.
Conformance to CSS Namespaces is defined for two classes:
The conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification. All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [[!RFC2119]]
Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with class="example",
like this:
This is an example of an informative example.
Informative notes begin with the word "Note" and are set apart from the
normative text with class="note", like this:
Note, this is an informative note.
@namespace empty ""; @namespace "";The type selectors
elem,
|elem,
and empty|elem
are equivalent.
@namespace "http://www.w3.org/1999/xhtml"; @namespace svg "http://www.w3.org/2000/svg";The first rule declares a default namespace
http://www.w3.org/1999/xhtml
to be applied to names that have no explicit namespace component.
The second rule declares a namespace prefix svg
that is used to apply the namespace http://www.w3.org/2000/svg
where the svg namespace prefix is used.
<qml:elem xmlns:qml="http://example.com/q-markup"></qml:elem>and the following ''@namespace'' declarations at the beginning of a CSS file:
@namespace Q "http://example.com/q-markup"; @namespace lq "http://example.com/q-markup";The selectors ''Q|elem'' and ''lq|elem'' in that CSS file would both match the element
<qml:elem>.
(The selector ''qml|elem'' would be invalid,
because CSS namespaces only recognize prefixes declared in CSS,
not those declared by the document language.)
namespace : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S* ; namespace_prefix : IDENT ;with the new token:
@{N}{A}{M}{E}{S}{P}{A}{C}{E} {return NAMESPACE_SYM;}
Any ''@namespace'' rules must follow all @charset and @import rules
and precede all other non-ignored at-rules and style rules in a style sheet.
For CSS syntax this adds [ namespace [S|CDO|CDC]* ]*
immediately after [ import [S|CDO|CDC]* ]* in the stylesheet grammar.
A syntactically invalid ''@namespace'' rule
(whether malformed or misplaced)
must be ignored.
A CSS style sheet containing an invalid ''@namespace'' rule
is not a valid style sheet.
A URI string parsed from the URI syntax must be treated as a literal string:
as with the STRING syntax,
no URI-specific normalization is applied.
All strings--
including the empty string and strings representing invalid URIs--
are valid namespace names in ''@namespace'' declarations.
|, U+007C).
The prefix, representing the namespace for which it has been declared,
indicates the namespace of the local name.
The prefix of a qualified name may be omitted to indicate that the name belongs to no namespace,
i.e. that the namespace name part of the expanded name has no value.
Some contexts (as defined by the host language)
may allow the use of an asterisk (*, U+002A)
as a wildcard prefix to indicate a name in any namespace,
including no namespace.
@namespace toto "http://toto.example.org"; @namespace "http://example.com/foo";In a context where the default namespace applies
toto|A
A
in the http://toto.example.org namespace.
|B
B
that belongs to no namespace.
*|C
C
in any namespace,
including no namespace.
D
D
in the http://example.com/foo namespace.
wqname)
and for qualified names that disallow wildcard prefixes (qname).
(The syntax uses notation from the Grammar appendix of CSS 2.1. [[!CSS21]]
Note this means that comments, but not white space, are implicitly allowed between tokens.):
qname_prefix : namespace_prefix? '|' ; wqname_prefix : [ namespace_prefix? | '*' ] '|' ; qname : qname_prefix? ident ; wqname : wqname_prefix? ident ; wqwname : wqname_prefix? [ ident | '*' ] ;CSS qualified names can be used in (for example) selectors and property values as described in other modules. Those modules must define handling of namespace prefixes that have not been properly declared. Such handling should treat undeclared namespace prefixes as a parsing error that will cause the selector or declaration (etc.) to be considered invalid and, in CSS, ignored.