CSS3 namespace selectors: writing an article

Actually, I can't take a decision: should I write an article in English or in Italian on CSS3 namespace selectors? I made a lot of tests on the subject. Currently, this feature is supported by Firefox, Opera, Safari and Chrome (IE is still hanging on). The fact is that my main web site is a mess: I got both /articles and /articoli directories. What's more, I recently started /appunti... gosh, that's a difficult situation!

So, what one could do with these selectors? Basically, if you have an XML document like this:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.site.com/ns/root" xmlns:test="http://www.site.com/ns/test">
  <element>Foo</element>
  <element:test>Test</element:test>
</root>

you cannot stylize the second child of the root element with a simple type selector, because this element lives inside its own namespace (sure, you could use an adjacent sibling combinator, but what happens if you have more than one element? you'll end up with a neverending chain of plus signs!). So here's why CSS3 namespace selectors are very useful: they allow you to stylize an XML document without having to transform it into HTML by using XSLT. Cool!

One thought on “CSS3 namespace selectors: writing an article”

Leave a Reply

Note: Only a member of this blog may post a comment.