W3C home > Mailing lists > Public > www-style@w3.org > July 2004

Re: pseudoclass based on document content

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Fri, 16 Jul 2004 14:52:11 -0700
Message-ID: <002f01c46b7f$26bac710$eb01000a@AFedoniouk>
To: "Justin Watt" <jwatt@email.unc.edu>, <www-style@w3.org>

> 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:31 GMT