3

If I have a div with a specific width, and it contains continuous content, then it will overflow. Is there a way to make it break the word and move part of it to the next line? e.g:

<div style="float:left;width:200px;">thiscontentwilloverflowthedivbecuaseitdoesnthaveanyspacesinit</div>

Thanks.

Andy Lobel
  • 3,226
  • 8
  • 30
  • 40
  • 1
    This is kinda like this: http://stackoverflow.com/questions/320184/how-to-prevent-long-words-from-breaking-my-div – jray Feb 03 '12 at 23:42

2 Answers2

10

add the following css:

overflow:hidden; word-wrap:break-word

word-wrap is css3 so it won't work with every browser

André Alçada Padez
  • 10,111
  • 22
  • 62
  • 114
0

use

overflow-wrap: break-word;

and here is it's compatibility.

https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap

Bharat
  • 5,419
  • 4
  • 35
  • 55