How to wrap long lines without spaces in HTML?

Chris Bartow picture Chris Bartow · Dec 12, 2008 · Viewed 82k times · Source

If a user types in a long line without any spaces or white space, it will break formating by going wider than the current element. Something like:

HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA.............................................................................................................................................

I've tried just using wordwrap() in PHP, but the problem with that is if there is a link or some other valid HTML, it breaks.

There seems to be a few options in CSS, but none of them work in all browsers. See word-wrap in IE.

How do you solve this problem?

Answer

Marcin picture Marcin · Oct 18, 2010

in CSS3:

word-wrap:break-word