00 Votes

CSS: Break long words if container is not big enough

Question by Guest | 2014-01-30 at 19:05

I have a DIV-container in my CSS-layout in which some very long words can appear from time to time (for example a long link).

I would like to force the behavior that long words are wrapped into the next line at the end of the box, because it looks very ugly when words are protruding beyond their area overlapping the other content of my website next to the corresponding text box.

In the Internet, I have read, that there is no possibility to code a hyphenation using CSS. Nevertheless, are there any possibilities to realize this line break?

0Best Answer0 Votes

Just try the CSS property "word-wrap":

word-wrap: break-word;

When setting "word-wrap" to "break-word" for the corresponding area, the result should exactly be the behavior, you have described.

The property "word-wrap" can take two different values. The default value is "normal". With this, words are only wrapped at the common break points such as line breaks. The value "break-word" also allows breaking within a word.
2014-01-31 at 13:06

ReplyPositive Negative

Related Topics

Scrollbar in DIV container

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.