Wrap a word without spaces in a div

I have a div that has a fixed width, 300px. I have user entered text that needs to go into a div. The problem is that people are investing in the word "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" in the case. This causes the text to exceed the width of the div. I would like the text to wrap around even if there are no spaces in the words. Is there a way to do this using css? I tried the css property white-space

but it didn't work.

If anyone has a solution or a point in the right direction would be great.

+3


source to share


2 answers


Try the following:



word-wrap:break-word;

      

+9


source


There is no way to do it right with the state of the art. Line break rules are complex and vary by language.



Using word-wrap:break-word

or some of its va riants arbitrarily breaks the rs string and almost certainly breaks the rules of the language and confuses people.

+1


source







All Articles