If I have a string like "11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110"
How can I get this string in my page to wrap? Here (stackoverflow) they do it.
Currently on my page it just displays on one line and flows way to the right ?
You can wrap a long string, which does not have any whitespace character by using the CSS word-wrap property, or overflow-wrap, if you use CSS3. In this snippet, you'll find some examples for block elements, as well as for the inline ones.
Today I'm going to talk about a rarely used but extremely useful CSS property, the word-wrap. You can force long (unbroken) text to wrap in a new line by specifying break-word with the word-wrap property.
break-word: This is the actual CSS syntax that tells the browser to wrap a long text over to a new line. normal: It breaks each word at the normal points of separation within a DOM. It doesn't have effect on long strings. initial: It's the default browser's way of handling strings.
With a word-wrap:break-word
:
<pre style="word-wrap: break-word;">LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG</pre>
Or:
<style type="text/css">
.wrapit{
word-wrap: break-word;
}
</style>
<div class="wrapit">LOOOOOOOOOOOOOOOONG</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With