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

String Pseudo-Element

From: Lachlan Hunt <lachlan.hunt@iinet.net.au>
Date: Tue, 18 May 2004 23:49:31 +1000
Message-ID: <40AA146B.3000107@iinet.net.au>
To: W3C Style List <www-style@w3.org>

   I've been reading over the current CSS3 Selectors CR — specifically, 
at the :contains() pseudo class.  It states that, since it's a 
pseudo-class it applies to the whole element that contains the text, not 
just the text within the element.  So, I'm asking why is there no 
pseudo-element that does just select the text within?

   For example, I'll use ::string() as the pseudo element, however, the 
exact name for it is not that important yet, and can be changed.

<h1>Hello World!</h1>

with the style
h1::string("World") { content: url(world.png); }

would create the fictional tag sequence like:
<h1>Hello <h1::string>World</h1::string>!</h1>

This would replace the text "World" with an image of the world, leaving 
the rest of the text unchanged.

   Since UAs will already be able to find elements that contain text 
because of the :contains() pseudo-class, it shouldn't be too hard to 
extend that to be able to surrond the text with a pseudo-element. 
Obviously I'm too late to be considered for the current Selectors 
Candidate Recomendation, but maybe the next time a new draft comes out, 
this idea could be included.

   I'm sure there would be lots of issues with this, such as how it 
handles multiple occurances of a string, or how it would handle 
overlapping occurances or any other issue you can think of.  So please, 
let me know what you think.

Lachlan Hunt

Received on Tuesday, 18 May 2004 09:49:46 UTC

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