How can I make text appear on next line instead of overflowing?

user342391 picture user342391 · Aug 27, 2010 · Viewed 237.2k times · Source

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

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

Is there anyway to disable overflow and put the overflowing text on a new line??? Twitter does something like this but I can't figure it out with CSS it's possible they are using Javascript.

Can anybody help with this??

Answer

Pankaj Verma picture Pankaj Verma · Sep 28, 2015

Just add

white-space: initial;

to the text, a line text will come automatically in the next line.