You can color the <wbr> tags in a long word. The browser will use them to break when necessary. If it is not necessary, it will not break. Here is an example of your jsfiddle fixed: http://jsfiddle.net/vAdPy/
Please note that the closer the <wbr> tags are to each other, the better the results you get, because the browser has more options to find a suitable place to break a long word.
Here is a PHP script to color the <wbr> tags in the text.
<?php $word = 'thisisaverylongword'; $wbr_word = preg_replace('/(..)/', '\\1<wbr>', $word);
Inserts the <wbr> after each two characters (note the two dots in the regular expression) of the long text. You can change the number of dots in a regular expression to control the distance between two consecutive <wbr> tags.
source share