If someone enters a very long title/sentence, the text will stretch across the web page.
Is there a way to break the text so it continues on to the next line?
Using overflow hidden will hide the text.
I think I should be using the wbr tag.
Should I use the insert(); method for this?
i.e.
string myText = "111111111111111111111111111111111111111111111111111111111111111111111111";
myText = myText.Insert(80, "<wbr/>");
Not sure how cross browser the wbr tag is also!
Strictly speaking, you should use the zero width space (
​) for this rather than<wbr>. However, Internet Explorer 6 and earlier are known not to support this (they show an ugly box). So<wbr>is probably the safest choice. Except… Internet Explorer 8 in standards mode is known not to support<wbr>, so you’ve got yourself a wonderful conundrum here.You can read more at quirksmode.org.
Do note HBoss’ comment in that it’s hard to predict where to break, unless you’re using a fixed width font like Courier. You should probably heed his advice and break more often than just every 80 characters. (And don’t get me started on combining characters.)
As far as ASP.NET is concerned, you can indeed use the
Insertmethod for this, but beware when you need to insert more than one: you” need to do some book keeping (and aStringBuilderwould also be advised).