Re: pseudoclass based on document content

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.

<HTML>
<HEAD>
<STYLE>
.negative {color:red;}
.financial {font-family:monospace;}
</STYLE>
</HEAD>

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



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