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,356
  • 9
  • 31
  • 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

11

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,987
  • 24
  • 67
  • 120
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,869
  • 4
  • 38
  • 58