The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Automatically set punctuation color. Re: Automatically set punctuation color.


With php you can use str_replace to find the character you want to replace and replace it with the same character wrapped in a span with a class which you can style in your css.

Here is an example using the content of a post in WordPress.

$content = str_replace('?', '?', get_the_content();
echo $content;

Normally you would just display the content with “ but first we can grab the content data and do some quick swaps inside the string before outputting it. Since this doesn’t use js it will work even if javascript it turned off and the styles are easily editable via css.