Namespace support in CSS3 style sheets is outlined in Selectors. In summary:
@namespace
rule declares a namespace prefix and associates it to the namespace URI. Examples:
@namespace url(http://www.xmlmind.com/xmleditor/schema/configuration); @namespace html url(http://www.w3.org/1999/xhtml);
Rule #1 specifies that element names (in selectors) without an explicit namespace component belong to the "http://www.xmlmind.com/xmleditor/schema/configuration
" namespace.
Rule #2 specifies that element or attribute names with a "html
" prefix belong to the "http://www.w3.org/1999/xhtml
" namespace.
Notation for qualified names is prefix
|
local_name
, where character '|'
is used to separate the two parts of the qualified name.
Example of element names:
@namespace ns url(http://www.ns.com); ns|para { font-size: 8pt; } ns|* { font-size: 9pt; } |para { font-size: 10pt; } *|para { font-size: 11pt; } para { font-size: 11pt; }
will match only para
elements in the "http://www.ns.com
" namespace.
will match all elements in the "http://www.ns.com
" namespace.
will match only para
elements without any declared namespace.
will match para
elements in any namespace (including those without any declared namespace).
is equivalent to the rule #4 because no default namespace has been defined.
Examples of attribute names:
@namespace ns "http://www.ns.com"; [ns|role=minor] { font-size: 8pt; } [*|role] { font-size: 9pt; } [|role] { font-size: 10pt; } [role] { font-size: 10pt; }
will match only elements with the attribute role
in the "http://www.ns.com
" namespace with the value "minor
".
will match only elements with the attribute role
regardless of the namespace of the attribute (including no declared namespace).
will match only elements with the attribute role
where the attribute is not declared to be in a namespace.
Note that default namespaces do not apply to attributes.
The attr()
pseudo-function also supports namespaces.
@namespace ns "http://www.ns.com"; para:before { content: attr(ns|role); }
The generated content inserted before "para
" elements is the content of attribute role
declared in the "http://www.ns.com
" namespace.