Break long word with CSS

dev1234 picture dev1234 · Sep 5, 2013 · Viewed 27.8k times · Source

I have a situation where there can be long words like 'hellowordsometext' or integer like '1234567891122' without any space in between. check this js please. http://jsfiddle.net/rzq5e/6/

how is it possible to break it in to next line after it reach the div width. what happens now is, it spans out out along with th div

<div>Solutionforentprise</div>

Answer

Mr. Alien picture Mr. Alien · Sep 5, 2013

What you need is word-wrap: break-word;, this property will force the non spaced string to break inside the div

Demo

div {
   width: 20px;
   word-wrap: break-word;
}