How can I make text on the next line instead of overflow?

I have a fixed width div on my page that contains text. When I enter a long string of letters, it overflows. I do not want to hide the overflow. I want to display overflow on a new line, see below:

<div id="textbox" style="width:400px; height:200px;"> dfssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssfddddddddddddddddddddddsdffffffffffffffffsdffffffffffffffffdfssssssssssssdf </div> 

In any case, disable the overflow and put the overflow text on a new line ??? Twitter does something like this, but I can't figure it out with CSS, maybe they use Javascript.

Can anyone help with this?

+43
css text overflow
Aug 27 '10 at 19:11
source share
4 answers
 word-wrap: break-word 

But this is CSS3 - http://www.css3.com/css-word-wrap/ .

+79
Aug 27 '10 at 19:15
source share

Just add

 white-space: initial; 

the text of the line will automatically appear in the next line.

+50
Sep 28 '15 at 7:37
source share

Try the <wbr> - not as elegant as the word-wrap property others have suggested, but it's a working solution as long as all major browsers (read IE) implement CSS3.

+5
Aug 27 '10 at 19:19
source share

Well, you can embed one or more soft hyphens ( &#173; ) in your long, continuous lines. I doubt that older versions of IE handle this correctly, but what it should do is tell the browser about valid word breaks that it can use if necessary.

Now, how exactly do you choose where to stuff these characters? It depends on the actual string and what it means, I think.

+3
Aug 27 '10 at 19:15
source share



All Articles