Re: : in CSS

> SL> When parsing CSS, how do you differentiate between elements which have
a :
> SL> in their name (like svg:svg) and pseudo elements/classes like
(svg:link)
>
> By noting that no elements have a colon in their name, it being
> reserved.
>
> Assuming that the namespace prefix svg is declared to map to
> http://www.w3.org/2000/svg then the qualified element name is the
> tuple
>
> local name = svg
> namespace = http://www.w3.org/2000/svg
>
> this would be used in a selector thus:
>
> @namespace foo url(http://www.w3.org/2000/svg);
>
> foo|svg { fill: purple }
>
> Not that this will match all occurrences of the svg element in the SVG
> namespace regardless of whether they use s:, svg: foobar: or nothing
> as their prefix. It will not match elements that happen to be called
> svg in some other namespace. Note that the choice of namespace prefix
> in the CSS is arbitrary and is unaffected by the choice of prefix or
> lack thereof in the file(s) that it is styling.
>
> The alternative that people might have considered trying, svg\:svg is
> bogus and harmful, because it pretends that the whole string is one
> local name and because it makes assumptions about what the namespace
> prefix is.
>

I am aware of the @namespace and | (But I thought this was only CSS3 and not
yet in a final recommendation)
But what you wrote last (\:) answered my question.

My question was because of the following from the CSS3 Selectors spec.

11. Namespaces and Down-Level Clients

....However, given complete knowledge of the XML document to which a style
sheet is to be applied, and a limited use of namespaces within the XML
document, it is possible to construct a style sheet in which selectors would
match elements and attributes correctly.

--
Sigurd Lerstad

Received on Wednesday, 19 February 2003 08:01:52 UTC