W3C home > Mailing lists > Public > www-style@w3.org > August 1999

Namespace qualifiers in CSS

From: L. David Baron <dbaron@fas.harvard.edu>
Date: Sat, 7 Aug 1999 12:34:24 -0400 (EDT)
Message-Id: <199908071634.MAA17739@ice1.fas.harvard.edu>
To: www-style@w3.org
As currently defined, any namespace qualifier in XML markup maps to a
unique namespace name so that elements and attributes can be identified
as being "in" a particular namespace.  However, CSS does not face the
same restriction.  A namespace qualifier can be mapped to multiple
names, since CSS selectors match elements rather than identify them.
This cannot be done in the current CSS3 Namespaces draft [1], but I
think it is an important feature.

It is important because elements that are approximately the same can be
identified with different namespaces.  For example, using the current
draft for xhtml [2], a custom namespace as described in chapter 6 of
XHTML modularization [3], and the de facto namespace name for HTML 4.0
[4] given in the xml namespaces draft [5], the following elements are
essentially equivalent:


Stylesheet authors may want to use one stylesheet for documents that use
this same element with different namespace identifiers.  This would be
very tedious if CSS did not allow namespace qualifiers to match multiple
namespaces.  For example, using the current proposal, a stylesheet would
look like:

@namespace html "http://www.w3.org/TR/REC-html40";
@namespace xhtml "http://www.w3.org/TR/xhtml1";
@namespcae xhtmlm "http://www.myorg.com/DTDs/myord.dtd";

html|p, xhtml|p, xhtmlm|p {
  text-indent: 1em;

This could become much more tedious for more complex selectors, even if
one assumed that no documents mixed namespaces (which may be a bad
assumption especially if external parsed entities are used).

Therefore, I propose that the definition for the @namespace rule given
in section 2 of [1] be changed to allow for multiple namespaces,
separated by commas:

namespace : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI]
            [ S* "," S* [STRING|URI] ]* S* ";" S*

and the rules in section 3 of [1] be changed so that the element may
match any of the namespaces given.

Thus the above stylesheet could be simplified to:

@namespace html "http://www.w3.org/TR/REC-html40",

html|p {
  text-indent: 1em;

(It could be simplified even further using default namespaces.)

This presents a slight difficulty for section 4 of [1], but I think the
attr() function should be defined to work around any potential

  If the namespace qualifier of the attribute name is identified with
  multiple namespaces, the attr() function will 'return' the value of
  the attribute in the first of those namespaces in which the attribute
  is defined on the element to which the declaration is being applied.
  If it exists in none, then it will return "".

However, this doesn't handle attributes with default values very well
(although one could simply let authors work around it).  It may still
be the best solution.


[1] http://www.w3.org/1999/06/25/WD-css3-namespace-19990625/
[2] http://www.w3.org/TR/xhtml1/
[3] http://www.w3.org/TR/xhtml-modularization/
[4] http://www.w3.org/TR/REC-html40/
[5] http://www.w3.org/TR/REC-xml-names

L. David Baron     Rising Sophomore, Harvard     dbaron@fas.harvard.edu
Links, SatPix, CSS, etc.        < http://www.fas.harvard.edu/~dbaron/ >
Summer Intern, Netscape - however, opinions are entirely my own, etc.
Received on Saturday, 7 August 1999 12:34:26 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:51 UTC