Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to force text to wrap in browser even when it is a consecutive string with no spaces?

Tags:

html

css

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 ?

like image 425
Chris Avatar asked Aug 25 '10 19:08

Chris


People also ask

How do you wrap text without space?

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.

How do you force text wrap in CSS?

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.

How do you wrap text in next line?

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.


1 Answers

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>
like image 68
Lekensteyn Avatar answered Oct 16 '22 17:10

Lekensteyn