Forum Moderators: not2easy

Message Too Old, No Replies

Namespaces in CSS

Gecko tested

         

Robin_reala

10:03 pm on Apr 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



(I crossposted this [forums.mozillazine.org] on Mozillazine but no answers, apologies if you've seen it there already)

Given:

<a href="" xml:lang="nl" lang="nl">#*$!</a>

why does:

a[lang]:after { content: " [" attr(lang) "]" }

correctly show '#*$! [nl]', but:

a[xml¦lang]:after { content: " [" attr(xml¦lang) "]" }

only show 'xxx' (with gecko 1.7)?

encyclo

11:36 am on Apr 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't have an answer to the question as to why Mozilla doesn't react as expected to your second rule, other than the general observation that user agent support for
xml:lang
is verging on non-existent - not surprising as when parsed as HTML (as virtually every page will be) the xml: syntax is pretty meaningless anyway.

However, I don't think you've got the right approach: the

lang
(or
xml:lang
) attribute defines the language of the contents between the
<a>
and
</a>
- but surely it would be more logical for the link to be marked with the language of the target document? For that, you can use the
hreflang
attribute. Here's a test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test template</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
[b]a[hreflang]:after { content: " [" attr(hreflang) "]" }[/b]
</style>
</head>
<body>
<p><a href="#" [b]hreflang="nl"[/b] lang="nl">test</a></p>
</body>
</html>

Robin_reala

12:16 pm on Apr 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Excellent points, all of which I've overlooked :) Yeah, I was serving as text/html so xml namespaced attributes might run into problems.

Wrt @lang, I was using it not only to signify the language of the page linked to, but also to signify the language of the link text. I've not seen @hreflang before, but in this case I assume I'd want to use both.

Thanks!

Robin_reala

9:29 pm on Apr 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jonnyq points out in my MZ thread that an @namespace rule is needed in the stylesheet to allow namespace processing. Also, it appears that the media type does have to be an xml one to get this working.