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

Re: pseudoclass based on document content

From: Justin Watt <jwatt@email.unc.edu>
Date: Sat, 17 Jul 2004 12:23:37 -0400 (EDT)
To: Lachlan Hunt <lachlan.hunt@iinet.net.au>
Cc: W3C Style List <www-style@w3.org>
Message-ID: <Pine.A41.4.44+UNC.0407171212560.34814-100000@login4.isis.unc.edu>

Both the NR tag and :contains pseudoclass seem to accomplish exactly what
I desire, probably more effectively and in a less complicated or backwards
compatibility sacrificing way (per Justin Wood) than a full-blown regex
pseudoclass would have invited.

Of course it doesn't seem that IE or mozilla support :contains yet :(

However the following worked fine in both browsers, so I'm not sure what
your "except for IE" comment was refering to.

.negative {color:red;}
.financial {font-family:monospace;}

<SPAN CLASS="financial negative">-190</SPAN>

On Sat, 17 Jul 2004, Lachlan Hunt wrote:
> I think what you really want here is something like the proposed <nr/>
> element in XHTML2 [1] if it had the ability to markup whether a number
> was positive or negative, but for now, there's no reason (except for IE)
> that you can't, as Andrew and Fantasai suggested, just use a space
> separate list of classes in the table cell and loose the superfluous
> style attribute element.
>    It could certainly be argued that using a minus sign, or surrounding
> the number in parentheses, or both is a matter of styling since all are
> used are used to represent negative numbers.  Although, usually a
> document will only use one format, so it could also be argued that it's
> just a matter of marking up correct content.
> Also, there is the ':contains' [2] pseudo class that may be able to be used.
> eg. .financial:contains("-") { colour: red; }
> [1]
> http://www.w3.org/TR/2003/WD-xhtml2-20030506/mod-inline-text.html#s_inline-textmodule_issue_1
> [2] http://www.w3.org/TR/css3-selectors/#content-selectors
> --
> Lachlan Hunt
> http://www.lachy.id.au/
> lachlan.hunt@lachy.id.au
Received on Saturday, 17 July 2004 12:23:48 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:14 UTC