W3C home > Mailing lists > Public > www-style@w3.org > November 2007

Re: Math WG Prioritized Requests

From: James Elmore <James.Elmore@cox.net>
Date: Thu, 15 Nov 2007 09:16:23 -0800
Message-Id: <40292318-A703-4C3F-ACE5-0F201AB4FB67@cox.net>
To: Brad Kemper <brkemper@comcast.net>, www-style Style <www-style@w3.org>

I suggested something similar a year back and was told that "that is  
not format, it is content." I agree with you that it would be very  
useful to be able to format based on strings or other, more complex  
pattern matches. I couldn't find my original email in the archives,  
perhaps it was before I joined the group, so I will copy some of it  
here so it gets archived.


I was considering the basic function of CSS (formatting HTML/XHTML/ 
etc. content) and found an area where CSS is lacking: formatting  
based on content. Simple examples:

	If a number is negative, print it in red.
	If a name (IBM) appears in a page, make the font larger and bold.
	Display all (American) monetary values with a dollar sign ($), a  
decimal point (.) and cents ("$f8.2" for example).

I recognize that this can be done with Javascript, but so can  
changing the style on MouseOver or on Focus. My thought was that CSS  
should handle formatting (style) and this ability is not present in  
the standard. As more web pages are dynamic, this could become very  


There are plenty of regular expression libraries/packages available,  
so the hardest part of implementation could use one of these. The  
rest depends on how much freedom/power to provide users. Do we want  
to limit to just strings, or provide strings plus some special  
characters (start and end of word, e.g., from your example) or allow  
a full regular expression parser? I would guess the group would not  
want the latter, but what would the users want?

I really think this would make CSS into a powerful formatting tool,  
allowing users to specify something like:

body:equals("\wIBM\w") { font-size: +1; font-weight: bold; }

Where one line of CSS can replace many <span class="CompanyLogo">IBM</ 
span> insertions. Again, yes -- this can be done server side, with  
programming or macros. But it seems to be a powerful formatting  
ability and a natural fit for CSS.

On Nov 15, 2007, at 8:46 AM, Brad Kemper wrote:

> It would be nice to have something like the following to, say, bold  
> all instances of my name in a document, without having to insert an  
> explicit span or B element into the HTML markup:
> BODY::equals("Brad Kemper") { font-weight:bold; }
> There are probably many use cases for such a pseudo-element, aside  
> from this frivolous example of my own name. So that instead of  
> going through a document highlighting or bolding every instance of  
> a word or phrase in the markup, you could just write a line into  
> the CSS.
> If such a thing existed, it might also be nice to match only the  
> item when it is within word boundaries, perhaps using regex notation:
> BODY::equals("Brad Kemper",\b) { font-weight:bold; }

James Elmore
Received on Thursday, 15 November 2007 17:16:43 UTC

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