I have a user control in my asp.net web project.
It displays the title of a blog post. If the title is too long, it will stretch the wrapped table and ruin the page layout.
Is there a way I can chop the text after 40 characters IF the text doesn’t contain a space in it?
How would I check for the existance of a space anywhere, and if not exist insert a space.
I’m looking for the ‘best practise’ as I’m sure this is a common problem for web apps.
The
<wbr/>tag was designed for this purpose. There are also some other html entities that can help with this. Essentially it suggests to the browser that this would be an ok place to break if the line gets too long.You can read more here:
http://www.quirksmode.org/oddsandends/wbr.html