Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css to replace characters in paragraph tag

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?

like image 505
Thariama Avatar asked Feb 19 '26 22:02

Thariama


2 Answers

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" />'));
});
like image 194
Gert Grenander Avatar answered Feb 21 '26 12:02

Gert Grenander


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.

like image 35
Tesserex Avatar answered Feb 21 '26 12:02

Tesserex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!