Search code examples
asp.netcss

asp.net continuous string wrap


Okay, so it seems, for some reason (I might be doing it wrong, obviously), that I have some problem wrapping continuous lines, using Asp.net.

Let's say I have 800 pixels worth of the "m" character, well, my table cell gets extended to that length. I don't want that, I want the cell to automatically break the continuous line after 300px.

To do that, I tried to apply the word-wrap:break-word css style. Didn't work. Now what?

Do I parse the line, to insert explicit linebreaks after a certain number of characters? That doesn't seem very clean to me. Any ideas?


Solution

  • You can insert a <wbr> (little known html element) every few m's. It's not 100% compatible with everything, but it works in most browsers:

    <wbr> (word break) means: "The browser may insert a line break here, if it wishes." It the browser does not think a line break necessary nothing happens.

    So you would do something like this:

    mmmmmmmmm<wbr>mmmmmmmmmm<wbr>mmmmmmmmmmm<wbr> (etc.)
    

    Here's some more info: http://www.quirksmode.org/oddsandends/wbr.html