Andy Lobel
Andy Lobel

Reputation: 3416

stop div content overflowing?

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.

Upvotes: 3

Views: 11673

Answers (2)

Bharat
Bharat

Reputation: 6095

use

overflow-wrap: break-word;

and here is it's compatibility.

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

Upvotes: 0

add the following css:

overflow:hidden; word-wrap:break-word

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

Upvotes: 11

Related Questions