Take the 2-minute tour ×

I have a div that is of fixed width, 300px. I have user inputed text that needs to go into the div. The issue is, is that people are putting the word "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" into the div. This causes the text to exceed the width of the div. What I would like is for the text to wrap even if there is no spaces in the words. Is there a way to do this with css? I tried the css white-space property but it was not working.

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

share|improve this question
possible duplicate of How to word wrap text in HTML? –  Jukka K. Korpela Apr 7 '12 at 4:33

2 Answers 2

up vote 2 down vote accepted

Try this:

share|improve this answer
Yeah!! Works like a charm –  Alexis Apr 7 '12 at 4:04

There is no way to do this properly, with the current state of the art. Line breaking rules are complex and vary by language.

Using word-wrap:break-word or some of its va riants arbitrarily breaks a string of characte rs and almost certainly breaks the rules of th e language and confuses people.

share|improve this answer

Your Answer


