CSS: breaking or wrapping long word to next line
Truncating long strings with CSS, forcing it to go to the next line if one line is not wide enough.
HTML
Read more about this solution on:
<br/><a href="http//stackoverflow.com/questions/320184/how-to-prevent-long-words-from-breaking-my-div" target="_blank">stackoverflow.com/questions/320184/how-to-prevent-long-words-from-breaking-my-div</a>
<br/><a href="http://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/" target="_blank">css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/</a>
<br/><a href="http://caniuse.com/#search=word-wrap" target="_blank">caniuse.com/#search=word-wrap</a>
<br/><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/word-wrap" target="_blank">developer.mozilla.org/en-US/docs/Web/CSS/word-wrap</a>
<br>
<br>
<br>
A very long word <b>not</b> formatted:
<br>
<br>
<div class="txt-container">averylonggermanwordthatshouldgotothenextlinebecausethereisnotenoughspace</div>
<br>
<br>
<br>
A very long word breaking/wrapping to the next line:
<br>
<br>
<div class="txt-container txt-container--break-long-word">averylonggermanwordthatshouldgotothenextlinebecausethereisnotenoughspace</div>
CSS
.txt-container{
width: 200px;
background-color: #E0E0E0;
overflow: hidden;
}
.txt-container--break-long-word {
word-break: break-word;
word-wrap: break-word;
}