Re: pseudoclass based on document content

> The benefit of this approach being that if negative numbers in your
> document are surrounded by parentheses, you can modify the regular
> expression in the stylesheet rather than having to modify your document to
> play nice with a UA's implementation of ":negative-number".

If you already have some code producing numbers in cells then why you cannot
change it to produce:
<td class="positive">123</td>
<td class="negative">-123</td>
<td class="undefined">(none)</td>
etc. ?

Just to keep it simple...

Andrew Fedoniouk.
http://terrainformatica.com


----- Original Message ----- 
From: "Justin Watt" <jwatt@email.unc.edu>
To: <www-style@w3.org>
Sent: Friday, July 16, 2004 2:40 PM
Subject: pseudoclass based on document content


>
> This might be something of a black hole, but has anyone thought about
> using pseudoclasses to apply style based on document content, as opposed
> to structure or other intrinsic qualities of structure?
>
> One example of what I mean is described here:
>
http://www.unc.edu/~jwatt/2004/07/css-pseudoclass-for-negative-numbers.html
>
> Let's say you have a table that has negative numbers in it. You want the
> negative numbers to appear red while the other numbers inherit their
> color.
>
> The might be "pseudo"-coded in CSS as:
>
> TD:negative-number {color:red;}
>
> The problem is that variations in content are infinite. So it probably
> wouldn't make sense to create a ":negative-number" pseudoclass because 100
> different people would probably request 100 different selectors for their
> special cases.
>
> Maybe there is a way to take advantage of simple pattern matching based on
> content, perhaps using regular expressions?
>
> The following might read: make the text inside TDs red if that text begins
> with a hypen (minus-sign) and ends with one or more other characters.
>
> TD:content-regex(/-.+/) {color:red;}
>
> The benefit of this approach being that if negative numbers in your
> document are surrounded by parentheses, you can modify the regular
> expression in the stylesheet rather than having to modify your document to
> play nice with a UA's implementation of ":negative-number".
>
> Thoughts?
>
> Justin Watt
>
>

Received on Friday, 16 July 2004 17:52:53 UTC