views:

99

answers:

3

Already checked exisitng questions for this, but didn't find an exact match.

My aim is to replace characters (like spaces) on a webpage with a small image using css.

Example:

<p><span>This is a text</span></p>

becomes:

<p><span>ThisIMGisIMGaIMGtext</span></p>

(where IMG stands for a visible image (middot-pic for a space f.e.))

I cannot think of a suitable css selector. But myabe one of you guys (or girls) know a solution. Is this possible at all?

+4  A: 

No, css doesn't have this ability. The only such things it can do are text-transform, which can do things like make it all uppercase.

Tesserex
Yup, I can't think of a way to do this either. You would need to put every word into an element, or replace the spaces by an element, to do something like this.
Pekka
thats what i thought (and feared)
Thariama
thx for your answer which confirmed my own opinion +1
Thariama
+3  A: 

Since you're not having an ID, I assume you want it on all <p><span>...</span></p>. jQuery will help you:

$(document).ready(function(){ 
  $("p span").html($("p span").html().replace(/ /g,'<img src="yourimg.gif" />'));
});
Gert G
+1 for alternative to impossible request.
Chris Lively
Thanks. Yeah, I can't think of a way to achieve it in CSS.
Gert G
thanks for your solution
Thariama
No problem, Thariama. :)
Gert G
+1  A: 

If a monochromatic image will suffice, you could use a custom web font that has the glyph of your choice in place of the usual empty space character (U+0020).

reisio
good idea - thx +1
Thariama