1

I just found the <wbr> element (link) which basically lets specific an area where a break could apply if needed.

Basically I'd like to implement it in my apps, to prevent breaking the layout due a comment in a blog with too many letters or signs.

The problem is: it has to be HTML compatible, so averylongmadeupandunnecesaryunspacedword might break apart each 25 characters but it won't break a link <a href="http://www.google.com/search?hl=en&source=hp&q=averylongandunnecesarywordingoogle&aq=f&aql=&aqi=&oq=">link</a>.

hippietrail
  • 15,848
  • 18
  • 99
  • 158
metrobalderas
  • 5,180
  • 7
  • 40
  • 47
  • 1
    Adding the tags regex and html together should automatically add a warning link to this page: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – Mark Byers Jan 22 '10 at 06:34
  • I know it's kind of pointless to try to parse HTML, but then again, what's the other option? Using a parser just to replace a little string that has a lot of characters? – metrobalderas Jan 22 '10 at 15:12
  • `` is for human-facing text. That is you use it in your example where you currently have `link`, not where you currently have `averylongandunnecesarywordingoogle` - that's a URL the user doesn't see! – hippietrail Nov 22 '12 at 10:38

1 Answers1

2

Have you considered using CSS? The word-wrap property is supported in IE, Safari, and FireFox 3.5

/* example */
.comments { word-wrap: break-word }

Also, <wbr> isn't supported on IE8 :(

Owen
  • 82,995
  • 21
  • 120
  • 115